gofmt and formatting
Let `gofmt` define ordinary formatting. Do not spend review energy on layout choices the tool already settled.
Canonical guidance
- run
gofmt - accept the tool’s layout decisions
- keep style debates above the formatting layer
Use when
- reviewing code style
- setting editor defaults
- deciding whether a diff needs manual layout cleanup
Avoid
- custom spacing conventions
- vertical alignment that
gofmtwill immediately undo - arguing over brace placement or indentation style
Preferred pattern
gofmt -w .
Anti-pattern
- hand-formatting code to preserve a personal visual layout
Explanation: This is tempting because manual alignment can look neat locally, but it creates noisy diffs and pointless style churn.
Why
- Go standardizes formatting so teams can spend attention on design and correctness
Related pages
Sources
- Effective Go - Go Team
- go command - Go Team