GO

GoFmt & GoImports

Standard Go formatting tools

Details

Language / Topic
goGo
Category
Linter / Formatter
Source
golang

Rules

balanced
- Always run `gofmt` (or `goimports`) on save. Go has one canonical formatting style — use it.
- Use `goimports` instead of `gofmt` — it also manages import statements automatically.
- Run `goimports` (or `gofumpt`) instead of just `gofmt` — it auto-manages import grouping and stricter formatting.
- Configure your editor to run `goimports` on save. Every Go file should be auto-formatted.
- `goimports` groups imports: standard library, third-party, internal — separated by blank lines.
- Run `go vet ./...` alongside formatting for catching common bugs (printf format strings, unreachable code).
- Use `golangci-lint` for comprehensive linting that includes `gofmt` and `govet` checks.