Track
Go
Review packages, exported APIs, errors, context, interfaces, goroutines, cleanup, tests, and HTTP handlers.
- 01
Package and file organization
Keep packages small, cohesive, and named by what callers need instead of by internal technical layers.
packagesorganizationboundaries - 02
Naming and exported APIs
Export only the names callers need and avoid repeating the package name inside exported identifiers.
namingapiexports - 03
Error handling and wrapping
Return errors with useful context and wrap underlying errors when callers should be able to inspect them.
errorswrappingsentinels - 04
Context cancellation
Accept context at API boundaries and pass it through I/O so cancellation, deadlines, and request scope are honored.
contextcancellationio - 05
Interfaces at boundaries
Define small interfaces where behavior is consumed instead of forcing every producer to satisfy a large package-wide contract.
interfacesdependenciestesting - 06
Struct validation and zero values
Design structs so zero values are either useful or validated before the value crosses an important boundary.
structsvalidationzero values - 07
Goroutines and channel ownership
Make goroutine lifetime and channel closing ownership explicit so concurrent code can stop cleanly.
goroutineschannelsconcurrency - 08
Defer and resource cleanup
Use defer close to make cleanup follow resource acquisition and cover every return path.
defercleanupresources - 09
Table-driven tests
Use table-driven tests to make related cases explicit while keeping each case named and independently diagnosable.
testingtable-drivencoverage - 10
JSON HTTP handler boundaries
Keep HTTP handlers focused on method checks, JSON decoding, validation, service calls, and response shape.
httpjsonhandlers