| >- No generics just mean you're going to be handing interface{} all the way in your stack, it makes things more complex and less readable for no reason (and less safe) Depends on what you do. I've written a good chunk of go code and interface{} is the rare exception rather than the rule, usually employed where a user might supply arbitrary types (ie a unmarshaljson like function) But if you do a website or webapp, 99% of your code is not using interface{} in it's methods. >- error handling which is essentially string-based, in 2017? Give me a type system, please You can put anything behind an error: type IntErr uint64
func (i IntErr) Error() string {
return strvonc.Atoi(i)
}
The string is only present when you either use the stdlib errors or you output an error.Additionally, nothing in Go forces you to actually use the error interface (sans stdlib). You can invent your own Error interface that uses ints. (Won't work with most external libraries but nothing is stopping you) Panic and Recover can to my knowledge both handle things that aren't errors; recover returns a interface{} that you check for value and type. You can put anything in there. >stability: the language itself is fine on that, but the ecosystem really isn't. A lot of projects focus on stability. If the API is breaking a lot they usually use Gopherpit or gopkg.in
to ensure compatibility in the future. In my experience, breaking the API is not something well used libraries do lightly (libraries with no or little use do break it sometimes since they lack the usage to refine it) If you need more, you can use vendoring. |
That's not really true. If you want an SQL database to back your website, then you'll deal with interface{} with Go's sql package. If you want to gzip your output, then you'll use interface{} with your writer.
To be fair, I think interface{} gets an almost unfair amount of hate. While it is fscking annoying when passing around core types (I hate having to use switch clauses just to inspect the type of an interface{}!!!) I do love how interface{} is used for complex structures. In fact there are a few areas of Go's standard library which I wish used interface{} more in that respect (eg Go's `file` struct should be an interface{} so I can create custom methods for os.Stdin/out/err)