The Unwritten Rules That Shape Every Go Code Review

The first six comments on your new Go pull request aren’t about logic—they’re about capitalization, receiver names, and a missing context parameter. Behind each nitpick sits the same page: the Go Code Review Comments wiki, the closest thing the language has to an official style council. Grown from years of feedback by Go’s own maintainers, the list quietly enforces ten rules that prevent real bugs rather than aesthetic preferences.
Why lowercase errors matter
Error messages in Go aren’t standalone sentences; they’re fragments stitched together with %w wrappers. Capitalizing the first word or ending with a period inserts visual noise into the final chain. A lowercase, unpunctuated error like “failed to open config” composes cleanly inside “load settings: %w”, yielding “load settings: failed to open config: permission denied”. The exception: strings that begin with an exported acronym such as HTTP or TLS retain their case.
Consistency beats flexibility with receivers
Choosing between value and pointer receivers isn’t decoration—it changes which methods a type actually offers. A Cache with mixed receivers suddenly presents a method set that is half value and half pointer, breaking interface satisfaction for callers who assumed one consistent shape. More importantly, if any method needs to mutate shared state (or embed a sync.Mutex), every method should use a pointer receiver; otherwise callers risk copying a value meant to be shared. Stick with the same short name—c for Cache—in every method to keep the noise down.
Context travels in parameters, not structs
A context.Context models the lifetime of a single call, not the lifetime of a struct. Storing it inside a struct invites stale deadlines and dangling cancellations across unrelated operations. Pass it explicitly as the first argument—always named ctx—so every function clearly declares its own cancellation boundary.
Source: DEV Community. AI-assisted editorial synthesis — TechnoExpress.

