"Common tips & mistakes" in Go — and How to Fix Them
summary
Practical fixes for common Go pitfalls: use an IDE for live import/unused-var checks, write table-driven tests and run linters like golangci-lint, and prefer returning errors over panics except at startup. Always defer resp.Body.Close() and capture its error with an anonymous defer, propagate context cancellations through call stacks, use utf8.RuneCountInString for character counts, crypto/rand for secure randomness, io.TeeReader to read a stream twice, and use goreleaser for cross‑compile releases.
AI-written summary · about
chapters (6)
- 0:00Start
- 2:24UNIT TESTS
- 3:46STATIC LINT
- 9:28CHECK ERRORS EVERYTIME
- 10:28BREAK CORRECTLY A LOOP/SWITCH
- 13:22MAPS USE DEFAULT ZERO VALUE








