40 lines
1.6 KiB
Markdown
40 lines
1.6 KiB
Markdown
# Linting
|
|
|
|
More importantly than any "blessed" set of linters, lint consistently across a
|
|
codebase.
|
|
|
|
We recommend using the following linters at a minimum, because we feel that they
|
|
help to catch the most common issues and also establish a high bar for code
|
|
quality without being unnecessarily prescriptive:
|
|
|
|
- [errcheck] to ensure that errors are handled
|
|
- [goimports] to format code and manage imports
|
|
- [revive] to point out common style mistakes
|
|
- [govet] to analyze code for common mistakes
|
|
- [staticcheck] to do various static analysis checks
|
|
|
|
[errcheck]: https://github.com/kisielk/errcheck
|
|
[goimports]: https://pkg.go.dev/golang.org/x/tools/cmd/goimports
|
|
[revive]: https://github.com/mgechev/revive
|
|
[govet]: https://pkg.go.dev/cmd/vet
|
|
[staticcheck]: https://staticcheck.dev
|
|
|
|
> **Note**: [revive] is the modern, faster successor to the now-deprecated [golint].
|
|
|
|
## Lint Runners
|
|
|
|
We recommend [golangci-lint] as the go-to lint runner for Go code, largely due
|
|
to its performance in larger codebases and ability to configure and use many
|
|
canonical linters at once. This repo has an example [.golangci.yml] config file
|
|
with recommended linters and settings.
|
|
|
|
golangci-lint has [various linters] available for use. The above linters are
|
|
recommended as a base set, and we encourage teams to add any additional linters
|
|
that make sense for their projects.
|
|
|
|
[golangci-lint]: https://github.com/golangci/golangci-lint
|
|
[.golangci.yml]: https://github.com/uber-go/guide/blob/master/.golangci.yml
|
|
[various linters]: https://golangci-lint.run/usage/linters/
|
|
[golint]: https://github.com/golang/lint
|
|
|