See: Golang Cheatsheet
Benefits
- Statically typed — fewer runtime bugs
- Fast builds, fast feedback loop
- Small binaries and containers — quick deploys, low memory usage
- Simple, explicit code; minimal magic
- Strong standard library — particularly for networking and HTTP
Shortcomings
Modern Go (1.22–1.27)
- Go 1.22 — per-iteration loop variable scoping (fixes the classic goroutine closure capture bug), range-over-int (
for i := range 10), and enhancedhttp.ServeMuxmethod/path parameter routing - Go 1.23 —
iterpackage and range-over-function iterators - Go 1.24 — Swiss-table map implementation for faster lookups and lower memory overhead
- Go 1.25 —
sync.WaitGroup.Go()helper for spawning tracked goroutines without manualAdd/Doneboilerplate - Go 1.27 (August 2026) —
encoding/json/v2GA, bringing faster, stricter, streaming-first JSON marshalling and unmarshalling
Concurrency
- Goroutines, channels,
select sync.Mutex,sync.RWMutex,sync.WaitGroup- Buffered vs unbuffered channels
- Production concurrency
- Context —
context.WithTimeout,context.WithCancel,context.WithoutCancel
HTTP / API Frameworks
- The standard library covers most needs (
net/http,http.ServeMux) - chi —
net/http-compatible router, idiomatic, well maintained - Echo — fuller framework if needed
JSON
- Use
json.Unmarshalfor one object,json.Decoderfor a stream - Go 1.27 stabilised
encoding/json/v2for improved performance, stricter defaults, and cleaner streaming APIs
Logging
- Use structured logging (slog in stdlib) to reduce allocations
- Add contextual fields (request ID, user, operation)
Testing
- testify — assertions
assertcontinues on failurerequirestops the test on failure
- httpexpect — API tests
- Run with
-raceto catch data races
Gotchas
- A map only grows, it never shrinks — recreate if memory matters (100 Go mistakes)
rangeproduces a copy- Avoid
init() - Slowloris / RUDY — set read and write timeouts on HTTP servers
- Define interfaces on the caller side, not the implementation side
- Slice gotchas
- Does Go have subtyping?
Compiling
- Statically linking Go
- Static Go
- cgo
- Consider goreleaser for release automation