golang-lint

Configure and run golangci-lint to enforce code quality in Go projects.

1|Updated May 25, 2020
One-click install
npx skills add https://github.com/titaneric/dotfiles --skill golang-lint-titaneric
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-lint
Source: https://github.com/titaneric/dotfiles/tree/main/dot_agents/skills/golang-lint
Command: npx skills add https://github.com/titaneric/dotfiles --skill golang-lint-titaneric

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires go, golangci-lint, and includes references (resource) and assets (resource) components.

What problem does it solve? Go projects often lack consistent linting configuration, leading to unchecked errors, resource leaks, and style drift. This Skill provides a production-ready golangci-lint setup and clear rules for interpreting, fixing, or suppressing lint warnings. ## Core Features & Use Cases - Recommended Configuration: Ships a v2 .golangci.yml with 48 linters organized by domain (correctness, style, complexity, performance, security, testing) plus documented reasons for disabled linters. - Suppression Discipline: Enforces //nolint:linter // reason directives with justification, backed by the nolintlint meta-linter, and guidance on when to fix versus suppress. - Legacy Adoption & Troubleshooting: Covers incremental adoption via issues.new-from-rev, parallel sub-agent cleanup by linter category, v1-to-v2 migration, and common errors like deadline exceeded. - Use Case: When adopting linting on a legacy Go codebase with thousands of warnings, use this Skill to lint only new code, auto-fix what is possible, and clean up the rest by linter category in parallel. ## Quick Start Ask the agent to set up golangci-lint for your Go project with a recommended .golangci.yml and explain any warnings it reports.

Frequently Asked Questions about golang-lint

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure golangci-lint for a Go project?

Create a .golangci.yml with version: "2" at the top, list linters under linters.enable, and put formatters like gofumpt under formatters.enable. Set run.timeout for large repos and per-linter options under linters.settings.

How do I suppress a golangci-lint warning with nolint?

Add //nolint:lintername on the flagged line with a justification comment, for example //nolint:errcheck // fire-and-forget logging. Never use bare //nolint, and suppress multiple linters with comma separation like //nolint:errcheck,gosec.

Which linters should I enable first in golangci-lint?

Prioritize correctness linters: govet, staticcheck, errcheck, and unused catch real bugs. Add at least one security or resource linter like bodyclose or gosec, and avoid redundant pairs such as gocyclo with cyclop.

How do I adopt golangci-lint on a legacy codebase with thousands of warnings?

Set issues.new-from-rev in .golangci.yml so only new or changed code is linted, then run golangci-lint run --fix for auto-fixable issues. Clean up remaining warnings gradually by linter category rather than mass-suppressing with nolint.

Why does golangci-lint report config errors after upgrading to v2?

golangci-lint v2 changed the configuration format, requiring a version field and a separate formatters section. Run golangci-lint migrate to convert a v1 config automatically.

When should I not suppress a lint warning?

Never suppress security and resource linters like gosec, bodyclose, or sqlclosecheck without strong justification, since they catch real leaks and vulnerabilities. Unchecked errors from errcheck on production paths should be fixed, not suppressed.