Hacker News new | past | comments | ask | show | jobs | submit login

I've been writing Go for quite a while, and probably used everything it's got to offer as a language. Go is opinionated, yes, however, for some crazy combination of reasons, it's amazing at getting out of your way for the most part.

Using interface{} instead of generics is a bad idea, you lose type safety. It's messy, but code generation is your other alternative, sort of like your own templating system. I've used go's built in templating code to generate type safe Go code from things like SQL table schemas. I'd highly recommend that route over naked interface{}

Error handling is string or type based, that's up to you. I declare specific error types for my functions, like FooError or BarError, the caller can then switch on err.(type) and respond appropriately. Alternately, you can define concrete error objects and return those, and make comparisons like "if err == FooError".

I'm with you that dependency management is terrible, vendoring is a poor workaround.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: