Go's code review ecosystem combines human review of pull requests with automated tooling: gofmt for formatting, go vet and staticcheck for correctness, golangci-lint for aggregated linters, and the race detector and tests in CI. Together they let reviewers spend their time on design, naming and behaviour instead of style, which improves quality and readability across a team.
Go also has strong shared conventions, such as the official Go Code Review Comments wiki page and Effective Go, so reviewers can point to a common standard instead of personal taste.
A code review is a systematic check of a change before it is merged. In Go projects it usually happens in a pull request on GitHub, GitLab or Bitbucket. Some teams, including the Go project itself, use Gerrit, where each commit is reviewed as a separate change.
A good review process has three layers:
Keeping the first layer strict means humans never have to comment on whitespace or import order.
Run these locally and in CI so the pull request arrives clean.
| Tool | What it checks |
|---|---|
gofmt or go fmt | Canonical formatting; there is no style debate in Go |
goimports | Formatting plus import grouping and removal of unused imports |
go vet | Suspicious constructs such as wrong Printf verbs or copied locks |
staticcheck | Bugs, deprecated APIs and simplifications |
golangci-lint | Runs many linters in one pass from a single config file |
go test -race ./... | Unit tests plus the data race detector |
govulncheck | Known vulnerabilities in dependencies and in the standard library you use |
A minimal CI sequence looks like this:
A small .golangci.yml pins which linters run so results are the same on every machine:
The version field belongs to golangci-lint v2 configuration; if you still run v1, use the v1 layout from its documentation instead.
Reviewers who follow the Go Code Review Comments guide tend to focus on the same recurring points.
Errors must be checked, wrapped with context and compared with errors.Is or errors.As, not by string matching.
A review comment here would flag any _ = err, any panic used for ordinary failures, and any message that starts with a capital letter or ends in punctuation.
// Server handles ....http.Client, not http.HTTPClient).s for Server), never this or self.Reviewers check that every goroutine has a clear way to stop, that a context.Context is the first parameter of functions that block, that defer releases files and locks, and that shared state is protected. The race detector catches many of these problems in tests, but only on code paths that tests actually run.
Prefer table-driven tests with subtests so cases are easy to add and review:
Since Go 1.22 each loop iteration has its own tc variable, so capturing it in a closure or a parallel subtest is safe without the old tc := tc copy.
Good feedback is what turns review into collaboration instead of gatekeeping.
nit: so the author knows what blocks the merge.Many teams add a CODEOWNERS file and branch protection so that a change needs at least one approval and green checks before merging.
| Platform or tool | Typical use |
|---|---|
| GitHub, GitLab, Bitbucket pull requests | Inline comments, required approvals, status checks |
| Gerrit | Per-commit review, used by the Go project itself |
| Reviewable and similar tools | Finer-grained review on top of GitHub |
gopls in your editor | Immediate diagnostics, formatting and refactoring before you commit |
go doc and pkg.go.dev | Check how an API is documented and intended to be used |
Yes. The Go wiki page "Go Code Review Comments" lists the common review points, and Effective Go describes idiomatic style. Many teams link to them in review comments.
Yes. Linters catch mechanical problems, but they cannot judge whether an abstraction is right, whether a function does what the ticket asked, or whether tests cover the real risks.
It depends on risk and team size. One reviewer plus strict automated checks is common; use two for security-sensitive code, public APIs and large refactors.
Aim for a single logical change that a reviewer can read in under half an hour. Split refactoring from behaviour changes so each can be reviewed on its own.
Go review works best when tools handle the objective rules (gofmt, go vet, staticcheck, golangci-lint, go test -race, govulncheck) and people handle design, clarity and risk. Follow the shared Go Code Review Comments conventions, keep changes small, give reasons with every comment, and require green checks plus approval before merging.