Go Cheatsheet
Power user.
Overview
Go is the systems language Google designed for cloud infrastructure work. Five primitives carry most of its appeal: goroutines and channels for lightweight concurrency, static typing with inference, first-class tooling (go fmt, go vet, go test, go mod), a well-engineered standard library, and single-binary deployment. Kubernetes, Docker, and Terraform all live in Go for these reasons.
- Goroutines and channels. Lightweight concurrency primitives. Scalable concurrent code without thread-per-request overhead.
- Static typing with inference. Compiler catches bugs without verbose declarations. Safety and readability together.
- Built-in tooling.
go fmt,go vet,go test,go mod. Toolchain bikeshedding disappears. - Standard library plus single-binary deploy. Net, http, encoding all well-engineered; cross-compiled static binaries simplify operational deployment.
The approach
Five idioms carry most of the operational weight. Memorising them moves the team from generic Go to idiomatic Go that the rest of the ecosystem reads naturally.
go fmtandgoimports. Standard formatting. Style debates retire; the tool decides.err != nil. Explicit error handling. Silent failures disappear because the language refuses to let them happen quietly.context.Context. First parameter for cancellation and deadlines. Correct timeout behaviour comes from idiomatic context propagation.deferplusgo test -race. Cleanup at scope exit avoids leaked resources; race detector catches subtle concurrency bugs at test time.
Why this compounds
Each idiomatic pattern raises the floor on team code quality. Goroutines remove a class of concurrency bugs; explicit error handling prevents the silent-failure class; context propagation produces correct cancellation across long stack traces.
- Concurrency improves. Goroutines and channels produce correct concurrent code. Race-condition bugs drop.
- Builds stay fast. Go’s compile speed preserves developer velocity even on large codebases.
- Operational simplicity. Single-binary deploys reduce operational surface. Production stays simpler than dynamic-language stacks.
- Year-one investment, year-two habit. First year builds idiom. By year two, the team writes Go that reads like Go.