Go has one style. It is enforced by the toolchain.
Run gofmt on everything. There is no debate about brace
placement, tab vs spaces, or alignment. The tool decides.
gofmt -w file.go
Or format an entire tree:
go fmt ./...
The canonical reference is Effective Go. Key points:
-er when
they have a single method.if can have an init statement. There is
no while -- use for. switch cases do not fall through
by default.// comments. Doc comments precede declarations
with no blank line between.Go was created by Rob Pike, Ken Thompson, and Robert Griesemer.
Its toolchain descends from the Plan 9 C compilers. The go
command is analogous to Plan 9's mk. The standard library
reflects Plan 9 sensibilities: small interfaces, composition
over inheritance, explicit error handling.
The style follows directly from Pike's notes on C: short names, no decoration, data structures over algorithms, measure before optimizing.