Loading...
Loading...
Recommended Go linters and golangci-lint configuration. Use when setting up linting for a Go project or configuring CI/CD.
npx skill4agent add cxuu/golang-skills go-lintingSource: Uber Go Style Guide
Source: Uber Go Style Guide
| Linter | Purpose |
|---|---|
| errcheck | Ensure errors are handled |
| goimports | Format code and manage imports |
| revive | Common style mistakes (modern replacement for golint) |
| govet | Analyze code for common mistakes |
| staticcheck | Various static analysis checks |
Note:is the modern, faster successor to the now-deprecatedrevive.golint
Source: Uber Go Style Guide
.golangci.ymllinters:
enable:
- errcheck
- goimports
- revive
- govet
- staticcheck
linters-settings:
goimports:
local-prefixes: github.com/your-org/your-repo
revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: error-return
- name: error-strings
- name: exported
run:
timeout: 5m# Install
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Run all linters
golangci-lint run
# Run on specific paths
golangci-lint run ./pkg/...| Task | Command/Action |
|---|---|
| Install golangci-lint | |
| Run linters | |
| Run on path | |
| Config file | |
| CI integration | Run |
| When you need... | Use |
|---|---|
| Error handling coverage | errcheck |
| Import formatting | goimports |
| Style consistency | revive |
| Bug detection | govet, staticcheck |
| All of the above | golangci-lint with config |
go-style-corego-testing