by Leon Rosenshein

GOLANG Oddities

Don't get me wrong, I like using go. It's clean, the standard library has almost everything I want/need, it's cross platform, and it's fast. VSCode, IntelliJ (and flavors), Emacs, and Vim have good support. Tabs vs spaces isn't a thing (gofmt has the one true answer). There are lots of people around that I can go to and get good answers. But

Golang is opinionated about where things go. GOPATH is king, and woe betide any who think they know better. Including your favorite IDE. IntelliJ/VSCode have their own ideas about how to build things and where they should go, and it's NOT bazel's idea. So we have things like setup-gopath and copy-genfiles.

Dependency hell. Golang sort of eliminates that, because there are not dependencies. You just copy everything you need into your GOPATH and build/link. Simple. Works great in a monorepo with no external decencies. But that's not our world. Go modules help, but there's still the version management problem.

Slices. Slices are not arrays. Repeat that a few times. Now do it again. There are lots of good reasons for slices to be what they are, and they let the compiler produce some very fast code. Just don't forget and you'll be OK. If you do forget things start to feel like quantum entanglement. Spooky action at a distance.

Type safety. But use …interface{} since you don't know what's coming and that lets you get anything and figure out what it is latter.

So what's your pet peeve and workaround? Share in the thread.