go-linting
Skill9 starsChanged 4 months agoMITView on GitHub
Use when setting up linting for a Go project, configuring golangci-lint, picking a linter set, suppressing findings with //nolint, or wiring lint checks into CI. Apply proactively whenever a project lacks .golangci.yml, when lint output is unclear, or when a new package needs the project's quality bar. Does not cover code review process (see go-code-review).
- Installs packages
3 other projects use a version of this.
Adopted by
Most recently taken up by
- cxuu/golang-skillstheir own version, first seen Jun 20, 2026
- abdullahkhawer/devops-skillstheir own version, first seen May 7, 2026
- saisudhir14/claude-skillstheir own version, first seen Mar 25, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- cxuu/golang-skills★ 165same name
- saisudhir14/claude-skills★ 9same name
- abdullahkhawer/devops-skills★ 8same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository26 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- go-clean-architectureSkill
- go-code-reviewSkill
- go-code-styleSkill
- go-concurrencySkill
- go-contextSkill
- go-control-flowSkill
- go-databaseSkill
- go-data-structuresSkill
- go-declarationsSkill
- go-defensiveSkill
- go-documentationSkill
- go-error-handlingSkill
- go-functional-optionsSkill
- go-functionsSkill
- go-genericsSkill
- go-graphqlSkill
- go-grpcSkill
- go-interfacesSkill
- go-loggingSkill
- go-namingSkill
- go-observabilitySkill
- go-packagesSkill
- go-performanceSkill
- go-swaggerSkill
- go-testingSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Add the CI workflow (see references/ci-integration.md).
- Very specific: line 43
Add formatting on top: gofmt / goimports (or gofumpt for stricter rules).
- Distinctive: line 113
Place the directive on the same line as the finding, or immediately above the construct it applies to.
- Very specific: line 114
Prefer per-line suppressions over file-level //nolint:all.
- Distinctive: line 143
Before merging a linting change:
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Go Linting
The single most important property of a linting setup is consistency: every contributor and every CI run uses the same rules. golangci-lint is the tool; a checked-in .golangci.yml is the contract.
Core Rules
- Every Go project has a
.golangci.ymlat the repository root. It is the source of truth for which linters run. - Lint runs in CI on every PR. A green build means lint is green.
- Lint runs locally before commit. A pre-commit hook or
make lintkeeps the feedback loop fast. - Suppress with reasons.
//nolint:linter // why— never bare//nolint. - Fix the cause first. A suppression should be the last resort, not the default reaction.
- Never silence security linters (
gosec,bodyclose,sqlclosecheck) without a strong, documented reason.
Setup Procedure
- Install:
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest(orbrew install golangci-lint). - Drop a baseline
.golangci.ymlat the repo root. - Run
golangci-lint run ./.... - Fix the findings in order — formatting first,
govetnext, style last. - Re-run until clean. Commit
.golangci.ymland any source fixes together. - Add the CI workflow (see references/ci-integration.md).
Minimum Linter Set
These five catch the most common issues and have the lowest noise rate. Start here:
| Linter | Catches |
errcheck | Unchecked error returns |
govet | Mistakes that compile but are wrong (printf args, shifts, etc.) |
staticcheck | Bug-prone patterns, dead code, simplifications |
ineffassign | Assignments whose value is never read |
revive | Style issues (modern replacement for golint) |
Add formatting on top: gofmt / goimports (or gofumpt for stricter rules). With golangci-lint v2 these run via golangci-lint fmt.
Recommended Additional Linters
Enable these once the baseline is clean:
| Linter | When to enable |
gosec | Any service that handles untrusted input |
bodyclose | Any code that calls http.Client.Do |
sqlclosecheck | Any code using database/sql |
nilerr | Any code that does if err != nil { return nil } style returns |
misspell | Always — comments and strings |
unconvert | Always — flags useless type conversions |
nolintlint | Always — enforces the //nolint rules below |
paralleltest | If most tests can use t.Parallel() |
thelper | If you write test helpers (enforces t.Helper()) |
testifylint | If the project uses testify |
gocyclo / gocognit | When you want a complexity ceiling |
exhaustive | When you use iota-based enums and want full switch coverage |
Read references/linter-catalog.md when picking from the long tail of correctness, style, security, and complexity linters, or when deciding which ones to enable on legacy code.
Development Workflow
lint:
golangci-lint run ./...
lint-fix:
golangci-lint run --fix ./...
fmt:
golangci-lint fmt ./...
ci-lint:
golangci-lint run --new-from-rev=origin/main ./...| Task | Command |
| Run all enabled linters | golangci-lint run ./... |
| Auto-fix everything fixable | golangci-lint run --fix ./... |
| Format the tree (v2+) | golangci-lint fmt ./... |
| Lint only changed code | golangci-lint run --new-from-rev=origin/main ./... |
| Run one linter | golangci-lint run --enable-only=govet ./... |
| Show which linters exist | golangci-lint linters |
--new-from-rev is what makes incremental adoption work: legacy code stays untouched, new and changed code must meet the bar.
Read references/ci-integration.md when wiring GitHub Actions, pre-commit hooks, or selective linting on PRs.
Suppressing Findings
// Good: specific linter + a reason
//nolint:errcheck // fire-and-forget; Sync error is not actionable on shutdown
_ = logger.Sync()// Bad: blanket, no reason — nolintlint will flag this
//nolint
_ = logger.Sync()Rules (enforced by nolintlint):
- Name the linter:
//nolint:errcheck, not//nolint. - Include a justification after
//. - Place the directive on the same line as the finding, or immediately above the construct it applies to.
- Prefer per-line suppressions over file-level
//nolint:all.
Read references/nolint-directives.md when deciding between inline, block, and file-scope suppressions, or when reviewing existing
//nolintfor stale rationale.
Interpreting Output
Each finding looks like:
path/to/file.go:42:10: message describing the issue (linter-name)The linter name in parentheses is the key — look it up in the catalog to see what it actually checks, then either fix the code or suppress with a reason that names the same linter.
Anti-Patterns
| Anti-pattern | Why it hurts | Do this instead |
No .golangci.yml in the repo | Each contributor lints differently or not at all | Commit a baseline config; CI enforces it |
//nolint with no linter name | Disables every check on that line, silently | //nolint:errcheck // reason |
//nolint:all at the top of a file | Whole file escapes review | Suppress per construct with a reason |
| Lint failures non-blocking in CI | "Green build" becomes meaningless | Block merges on lint failure |
| Enabling 100 linters on day one | Noise drowns signal; team gives up | Start with the minimum set, add gradually |
Suppressing gosec / bodyclose without justification | Silently hides real bugs | Fix the cause; if you can't, document why in the suppression |
| Different lint versions in dev vs CI | "Works on my machine" comes back | Pin the version in CI and document it in the README |
| Linting after the fact, only in CI | Slow iteration; PRs ping-pong | Run locally via make lint or a pre-commit hook |
Verification Checklist
Before merging a linting change:
.golangci.ymlexists at the repo root and is checked ingolangci-lint run ./...is clean (or--new-from-revreports no new issues)- CI runs
golangci-lintand blocks merges on failure nolintlintis enabled; no bare//nolintremains- Every
//nolintincludes a linter name and a one-line reason - Security linters (
gosec,bodyclose,sqlclosecheck) are enabled where applicable
References
- assets/.golangci.yml — production-ready baseline configuration
- references/linter-catalog.md — what each linter checks and when to enable it
- references/nolint-directives.md — suppression patterns, scoping rules, anti-patterns
- references/ci-integration.md — GitHub Actions, pre-commit hooks, incremental adoption
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

