{"id":"92cdc58c-6396-4822-aa3f-b49008011bd9","shortId":"kAycTA","kind":"skill","title":"go-linting","tagline":"Use when setting up linting for a Go project, configuring golangci-lint, or adding Go checks to a CI/CD pipeline. Also use when starting a new Go project and deciding which linters to enable, even if the user only asks about \"code quality\" or \"static analysis\" without mentioning ","description":"# Go Linting\n\n## Core Principle\n\nMore important than any \"blessed\" set of linters: **lint consistently across a codebase**.\n\nConsistent linting helps catch common issues and establishes a high bar for code quality without being unnecessarily prescriptive.\n\n---\n\n## Setup Procedure\n\n1. Create `.golangci.yml` using the configuration below\n2. Run `golangci-lint run ./...`\n3. If errors appear, fix them category by category (formatting first, then vet, then style)\n4. Re-run until clean\n\n---\n\n## Minimum Recommended Linters\n\nThese linters catch the most common issues while maintaining a high quality bar:\n\n| Linter | Purpose |\n|--------|---------|\n| [errcheck](https://github.com/kisielk/errcheck) | Ensure errors are handled |\n| [goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports) | Format code and manage imports |\n| [revive](https://github.com/mgechev/revive) | Common style mistakes (modern replacement for golint) |\n| [govet](https://pkg.go.dev/cmd/vet) | Analyze code for common mistakes |\n| [staticcheck](https://staticcheck.dev) | Various static analysis checks |\n\n> **Note**: `revive` is the modern, faster successor to the now-deprecated `golint`.\n\n---\n\n## Lint Runner: golangci-lint\n\nUse [golangci-lint](https://github.com/golangci/golangci-lint) as your lint runner. See the [example .golangci.yml](https://github.com/uber-go/guide/blob/master/.golangci.yml) from uber-go/guide.\n\n---\n\n## Example Configuration\n\n> See `assets/golangci.yml` when creating a new `.golangci.yml` or comparing your existing config against a recommended baseline.\n\nCreate `.golangci.yml` in your project root:\n\n```yaml\nlinters:\n  enable:\n    - errcheck\n    - goimports\n    - revive\n    - govet\n    - staticcheck\n\nlinters-settings:\n  goimports:\n    local-prefixes: github.com/your-org/your-repo\n  revive:\n    rules:\n      - name: blank-imports\n      - name: context-as-argument\n      - name: error-return\n      - name: error-strings\n      - name: exported\n\nrun:\n  timeout: 5m\n```\n\n### Running\n\n```bash\n# Install\ngo install github.com/golangci/golangci-lint/cmd/golangci-lint@latest\n\n# Run all linters\ngolangci-lint run\n\n# Run on specific paths\ngolangci-lint run ./pkg/...\n```\n\n---\n\n## Additional Recommended Linters\n\nBeyond the minimum set, consider these for production projects:\n\n| Linter | Purpose | When to enable |\n|--------|---------|----------------|\n| [gosec](https://github.com/securego/gosec) | Security vulnerability detection | Always for services handling user input |\n| [ineffassign](https://github.com/gordonklaus/ineffassign) | Detect ineffectual assignments | Always — catches dead code |\n| [misspell](https://github.com/client9/misspell) | Correct common misspellings in comments/strings | Always |\n| [gocyclo](https://github.com/fzipp/gocyclo) | Cyclomatic complexity threshold | When functions exceed ~15 complexity |\n| [exhaustive](https://github.com/nishanths/exhaustive) | Ensure switch covers all enum values | When using iota enums |\n| [bodyclose](https://github.com/timakin/bodyclose) | Detect unclosed HTTP response bodies | Always for HTTP client code |\n\n---\n\n## Nolint Directives\n\nWhen suppressing a lint finding, always explain why:\n\n```go\n//nolint:errcheck // fire-and-forget logging; error is not actionable\n_ = logger.Sync()\n```\n\nRules:\n- Use `//nolint:lintername` — never bare `//nolint`\n- Place the comment on the same line as the finding\n- Include a justification after `//`\n\n---\n\n## CI/CD Integration\n\n### GitHub Actions\n\n```yaml\n# .github/workflows/lint.yml\nname: Lint\non: [push, pull_request]\njobs:\n  lint:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - uses: actions/setup-go@v5\n        with:\n          go-version: stable\n      - uses: golangci/golangci-lint-action@v6\n        with:\n          version: latest\n```\n\n### Pre-commit Hook\n\n```bash\n#!/bin/sh\n# .git/hooks/pre-commit\ngolangci-lint run --new-from-rev=HEAD~1\n```\n\nUse `--new-from-rev` to lint only changed code, keeping the feedback loop fast.\n\n---\n\n## Available Scripts\n\n- **`scripts/setup-lint.sh`** — Generates `.golangci.yml` and runs initial lint\n\n```bash\nbash scripts/setup-lint.sh github.com/your-org/your-repo\nbash scripts/setup-lint.sh --force github.com/your-org/your-repo  # overwrite existing\nbash scripts/setup-lint.sh --dry-run                               # preview config\nbash scripts/setup-lint.sh --json                                  # structured output\n```\n\n> **Validation**: After generating `.golangci.yml`, run `golangci-lint run ./...` to verify the configuration is valid and produces expected output. If it fails with a config error, fix and retry.\n\n> `scripts/setup-lint.sh` generates a **minimum** config (5 core linters).\n> For established projects, use `assets/golangci.yml` as a starting point —\n> it adds gosec, ineffassign, misspell, gocyclo, and bodyclose.\n\n---\n\n## Quick Reference\n\n| Task | Command/Action |\n|------|----------------|\n| Install golangci-lint | `go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest` |\n| Run linters | `golangci-lint run` |\n| Run on path | `golangci-lint run ./pkg/...` |\n| Config file | `.golangci.yml` in project root |\n| CI integration | Run `golangci-lint run` in pipeline |\n| Nolint directives | `//nolint:name // reason` — never bare `//nolint` |\n| CI integration | Use `golangci/golangci-lint-action` for GitHub Actions |\n| Pre-commit | `golangci-lint run --new-from-rev=HEAD~1` |\n\n### Linter Selection Guidelines\n\n| When you need... | Use |\n|------------------|-----|\n| Error handling coverage | errcheck |\n| Import formatting | goimports |\n| Style consistency | revive |\n| Bug detection | govet, staticcheck |\n| All of the above | golangci-lint with config |\n\n---\n\n## Related Skills\n\n- **Style foundations**: See [go-style-core](../go-style-core/SKILL.md) when resolving style questions that linters enforce (formatting, nesting, naming)\n- **Code review**: See [go-code-review](../go-code-review/SKILL.md) when combining linter output with a manual review checklist\n- **Error handling**: See [go-error-handling](../go-error-handling/SKILL.md) when errcheck flags unhandled errors and you need to decide how to handle them\n- **Testing**: See [go-testing](../go-testing/SKILL.md) when running linters alongside tests in CI pipelines","tags":["linting","golang","skills","cxuu","agent-skills","ai-agent","ai-assistant","claude","claude-code","codex","cursor","llm"],"capabilities":["skill","source-cxuu","skill-go-linting","topic-agent-skills","topic-ai-agent","topic-ai-assistant","topic-claude","topic-claude-code","topic-codex","topic-cursor","topic-golang","topic-llm"],"categories":["golang-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/cxuu/golang-skills/go-linting","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add cxuu/golang-skills","source_repo":"https://github.com/cxuu/golang-skills","install_from":"skills.sh"}},"qualityScore":"0.491","qualityRationale":"deterministic score 0.49 from registry signals: · indexed on github topic:agent-skills · 82 github stars · SKILL.md body (6,256 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-02T12:55:18.655Z","embedding":null,"createdAt":"2026-04-18T22:13:17.380Z","updatedAt":"2026-05-02T12:55:18.655Z","lastSeenAt":"2026-05-02T12:55:18.655Z","tsv":"'/bin/sh':494 '/client9/misspell)':360 '/cmd/vet)':173 '/fzipp/gocyclo)':370 '/go-code-review/skill.md':737 '/go-error-handling/skill.md':754 '/go-style-core/skill.md':719 '/go-testing/skill.md':774 '/golang.org/x/tools/cmd/goimports)':153 '/golangci/golangci-lint)':209 '/golangci/golangci-lint/cmd/golangci-lint@latest':299,622 '/gordonklaus/ineffassign)':349 '/guide':225 '/kisielk/errcheck)':145 '/mgechev/revive)':162 '/nishanths/exhaustive)':382 '/nolint':418,432,436,654,659 '/pkg':315,636 '/securego/gosec)':336 '/timakin/bodyclose)':396 '/uber-go/guide/blob/master/.golangci.yml)':220 '/your-org/your-repo':267,535,541 '1':90 '15':377 '2':97 '3':103 '4':118 '5':590 '5m':291 'across':67 'action':428,454,666 'actions/checkout':473 'actions/setup-go':476 'ad':18 'add':603 'addit':316 'alongsid':778 'also':25 'alway':340,353,366,402,414 'analysi':50,183 'analyz':174 'appear':106 'argument':278 'ask':44 'assets/golangci.yml':229,597 'assign':352 'avail':521 'bar':80,139 'bare':435,658 'baselin':243 'bash':293,493,530,531,536,544,551 'beyond':319 'blank':272 'blank-import':271 'bless':61 'bodi':401 'bodyclos':393,609 'bug':697 'catch':73,129,354 'categori':109,111 'chang':514 'check':20,184 'checklist':746 'ci':643,660,781 'ci/cd':23,451 'clean':123 'client':405 'code':46,82,155,175,356,406,515,730,735 'codebas':69 'combin':739 'command/action':613 'comment':439 'comments/strings':365 'commit':491,669 'common':74,132,163,177,362 'compar':236 'complex':372,378 'config':239,550,580,589,637,709 'configur':13,95,227,568 'consid':323 'consist':66,70,695 'context':276 'context-as-argu':275 'core':55,591,718 'correct':361 'cover':385 'coverag':689 'creat':91,231,244 'cyclomat':371 'dead':355 'decid':34,764 'deprec':196 'detect':339,350,397,698 'direct':408,653 'dri':547 'dry-run':546 'enabl':38,252,332 'enforc':726 'ensur':146,383 'enum':387,392 'errcheck':142,253,419,690,756 'error':105,147,281,285,425,581,687,747,752,759 'error-return':280 'error-str':284 'establish':77,594 'even':39 'exampl':216,226 'exceed':376 'exhaust':379 'exist':238,543 'expect':573 'explain':415 'export':288 'fail':577 'fast':520 'faster':190 'feedback':518 'file':638 'find':413,446 'fire':421 'fire-and-forget':420 'first':113 'fix':107,582 'flag':757 'forc':538 'forget':423 'format':112,154,692,727 'foundat':713 'function':375 'generat':524,558,586 'git/hooks/pre-commit':495 'github':453,665 'github.com':144,161,208,219,266,298,335,348,359,369,381,395,534,540,621 'github.com/client9/misspell)':358 'github.com/fzipp/gocyclo)':368 'github.com/golangci/golangci-lint)':207 'github.com/golangci/golangci-lint/cmd/golangci-lint@latest':297,620 'github.com/gordonklaus/ineffassign)':347 'github.com/kisielk/errcheck)':143 'github.com/mgechev/revive)':160 'github.com/nishanths/exhaustive)':380 'github.com/securego/gosec)':334 'github.com/timakin/bodyclose)':394 'github.com/uber-go/guide/blob/master/.golangci.yml)':218 'github.com/your-org/your-repo':265,533,539 'github/workflows/lint.yml':456 'go':2,11,19,31,53,224,295,417,480,618,716,734,751,772 'go-code-review':733 'go-error-handl':750 'go-lint':1 'go-style-cor':715 'go-test':771 'go-vers':479 'gocyclo':367,607 'goimport':150,254,261,693 'golangci':15,100,201,205,304,312,497,562,616,626,633,647,671,706 'golangci-lint':14,99,200,204,303,311,496,561,615,625,632,646,670,705 'golangci.yml':92,217,234,245,525,559,639 'golangci/golangci-lint-action':484,663 'golint':169,197 'gosec':333,604 'govet':170,256,699 'guidelin':682 'handl':149,343,688,748,753,767 'head':504,678 'help':72 'high':79,137 'hook':492 'http':399,404 'import':58,158,273,691 'includ':447 'ineffassign':346,605 'ineffectu':351 'initi':528 'input':345 'instal':294,296,614,619 'integr':452,644,661 'iota':391 'issu':75,133 'job':463 'json':553 'justif':449 'keep':516 'latest':470,488 'line':443 'lint':3,8,16,54,65,71,101,198,202,206,212,305,313,412,458,464,498,512,529,563,617,627,634,648,672,707 'linter':36,64,126,128,140,251,259,302,318,328,592,624,680,725,740,777 'linternam':433 'linters-set':258 'local':263 'local-prefix':262 'log':424 'logger.sync':429 'loop':519 'maintain':135 'manag':157 'manual':744 'mention':52 'minimum':124,321,588 'misspel':357,363,606 'mistak':165,178 'modern':166,189 'name':270,274,279,283,287,457,655,729 'need':685,762 'nest':728 'never':434,657 'new':30,233,501,508,675 'new-from-rev':500,507,674 'nolint':407,652 'note':185 'now-deprec':194 'output':555,574,741 'overwrit':542 'path':310,631 'pipelin':24,651,782 'pkg.go.dev':152,172 'pkg.go.dev/cmd/vet)':171 'pkg.go.dev/golang.org/x/tools/cmd/goimports)':151 'place':437 'point':601 'pre':490,668 'pre-commit':489,667 'prefix':264 'prescript':87 'preview':549 'principl':56 'procedur':89 'produc':572 'product':326 'project':12,32,248,327,595,641 'pull':461 'purpos':141,329 'push':460 'qualiti':47,83,138 'question':723 'quick':610 're':120 're-run':119 'reason':656 'recommend':125,242,317 'refer':611 'relat':710 'replac':167 'request':462 'resolv':721 'respons':400 'retri':584 'return':282 'rev':503,510,677 'review':731,736,745 'reviv':159,186,255,268,696 'root':249,642 'rule':269,430 'run':98,102,121,289,292,300,306,307,314,466,499,527,548,560,564,623,628,629,635,645,649,673,776 'runner':199,213 'runs-on':465 'script':522 'scripts/setup-lint.sh':523,532,537,545,552,585 'secur':337 'see':214,228,714,732,749,770 'select':681 'servic':342 'set':6,62,260,322 'setup':88 'skill':711 'skill-go-linting' 'source-cxuu' 'specif':309 'stabl':482 'start':28,600 'static':49,182 'staticcheck':179,257,700 'staticcheck.dev':180 'step':471 'string':286 'structur':554 'style':117,164,694,712,717,722 'successor':191 'suppress':410 'switch':384 'task':612 'test':769,773,779 'threshold':373 'timeout':290 'topic-agent-skills' 'topic-ai-agent' 'topic-ai-assistant' 'topic-claude' 'topic-claude-code' 'topic-codex' 'topic-cursor' 'topic-golang' 'topic-llm' 'uber':223 'uber-go':222 'ubuntu':469 'ubuntu-latest':468 'unclos':398 'unhandl':758 'unnecessarili':86 'use':4,26,93,203,390,431,472,475,483,506,596,662,686 'user':42,344 'v4':474 'v5':477 'v6':485 'valid':556,570 'valu':388 'various':181 'verifi':566 'version':481,487 'vet':115 'vulner':338 'without':51,84 'yaml':250,455 '~1':505,679","prices":[{"id":"d5d3ec46-cbc6-4772-baf6-b38473b9ae32","listingId":"92cdc58c-6396-4822-aa3f-b49008011bd9","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"cxuu","category":"golang-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T22:13:17.380Z"}],"sources":[{"listingId":"92cdc58c-6396-4822-aa3f-b49008011bd9","source":"github","sourceId":"cxuu/golang-skills/go-linting","sourceUrl":"https://github.com/cxuu/golang-skills/tree/main/skills/go-linting","isPrimary":false,"firstSeenAt":"2026-04-18T22:13:17.380Z","lastSeenAt":"2026-05-02T12:55:18.655Z"}],"details":{"listingId":"92cdc58c-6396-4822-aa3f-b49008011bd9","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"cxuu","slug":"go-linting","github":{"repo":"cxuu/golang-skills","stars":82,"topics":["agent-skills","ai-agent","ai-assistant","claude","claude-code","codex","cursor","go","golang","llm"],"license":"apache-2.0","html_url":"https://github.com/cxuu/golang-skills","pushed_at":"2026-03-15T19:32:10Z","description":"AI Agent Skills for idiomatic, production-ready Go code, distilled from Google, Uber, Community","skill_md_sha":"c999a7d5e558685a33935e221cd8a48ce0387e76","skill_md_path":"skills/go-linting/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/cxuu/golang-skills/tree/main/skills/go-linting"},"layout":"multi","source":"github","category":"golang-skills","frontmatter":{"name":"go-linting","license":"Apache-2.0","description":"Use when setting up linting for a Go project, configuring golangci-lint, or adding Go checks to a CI/CD pipeline. Also use when starting a new Go project and deciding which linters to enable, even if the user only asks about \"code quality\" or \"static analysis\" without mentioning specific linter names. Does not cover code review process (see go-code-review)."},"skills_sh_url":"https://skills.sh/cxuu/golang-skills/go-linting"},"updatedAt":"2026-05-02T12:55:18.655Z"}}