There are 3 tools/tricks which are pretty essential to writing Go code on a team or open source project which I highly recommend:
-
Set up your editor to automatically run the code through
goimports
once you hit save.It's extremely fast. It formats your code using the standard
gofmt
tool. It automatically adds/removes/organizes your import lines. Note that Go uses tabs, so I recommend setting your editor's tab-width to 2 or 4, whichever you're used to. Anything but 8. Editor support: -
Run your code through go vet it will catch some unexpected things that the compiler might miss.
Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string. Vet uses heuristics that do not guarantee all reports are genuine problems, but it can find errors not caught by the compilers.
-
Run your code through golint to round-out your style. It generally beats people up about naming and comments.
Rock on.