Skills Agentes

Golang Lint

Buenas prácticas de linting y configuración de golangci-lint para proyectos Golang: ejecutar linters, configurar .golangci.yml, suprimir avisos con nolint, interpretar salidas y elegir linters.

Solicitaread edit write glob grep bash(go:*) bash(golangci-lint:*) bash(git:*) agent
Estrellas
3k

en todo el repo

Actividad
67

0–100, la ruta de este skill

Actualizado
hace 3 días

último commit aquí

Commits
8

últimos 90 días

Contexto
1.8k tok

109 tok en reposo

Paquete
5 archivos

41 KB

Instalar

Funciona con cualquier agente que lea SKILL.md

npx -y skills add samber/cc-skills-golang --skill golang-lint --agent claude-code

Se instala solo en este repositorio.

Qué hace

  • Configura y ejecuta golangci-lint con un archivo .golangci.yml de referencia con hasta 48 linters
  • Explica cómo suprimir advertencias con directivas //nolint incluyendo linter y justificación
  • Interpreta la salida de los linters y ayuda a elegir qué linters activar
  • Orquesta hasta 5 sub-agentes en paralelo para limpiar código legacy por categorías de linters

Úsalo cuando

  • Al configurar golangci-lint o el archivo .golangci.yml
  • Cuando surgen dudas sobre advertencias de lint o supresiones con nolint
  • Al configurar herramientas de calidad de código en el proyecto
  • Cuando el usuario menciona golangci-lint, go vet, staticcheck o revive

No lo uses cuando

    Qué lo activa

    Di cualquiera de estas frases y el agente debería cargar este skill.

    • Ayúdame a configurar el .golangci.yml de mi proyecto Go
    • ¿Por qué golangci-lint marca este error y cómo lo suprimo?
    • Quiero limpiar los warnings de lint en un proyecto Go legacy
    • ¿Qué linters debería activar para mi proyecto Go?

    SKILL.md

    En inglés

    Persona: You are a Go code quality engineer. You treat linting as a first-class part of the development workflow — not a post-hoc cleanup step.

    Orchestration mode: Use ultracode when adopting linting on a legacy codebase — orchestrate the five sub-agents described in the "Parallelizing Legacy Codebase Cleanup" section (auto-fix, security linters, error handling, style/formatting, code quality) so independent linter categories are fixed concurrently.

    Modes:

    • Setup mode — configuring .golangci.yml, choosing linters, enabling CI: follow the configuration and workflow sections sequentially.
    • Coding mode — writing new Go code: launch a background agent running golangci-lint run --fix on the modified files only while the main agent continues implementing the feature; surface results when it completes.
    • Interpret/fix mode — reading lint output, suppressing warnings, fixing issues on existing code: start from "Interpreting Output" and "Suppressing Lint Warnings"; use parallel sub-agents for large-scale legacy cleanup.

    Dependencies:

    • golangci-lint: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

    Go Linting

    Overview

    golangci-lint is the standard Go linting tool. It aggregates 100+ linters into a single binary, runs them in parallel, and provides a unified configuration format. Run it frequently during development and always in CI.

    Every Go project MUST have a .golangci.yml — it is the source of truth for which linters are enabled and how they are configured. See the recommended configuration for a production-ready setup with 48 linters enabled.

    Quick Reference

    # Run all configured linters
    golangci-lint run ./...
    
    # Auto-fix issues where possible
    golangci-lint run --fix ./...
    
    # Format code (golangci-lint v2+)
    golangci-lint fmt ./...
    
    # Run a single linter only
    golangci-lint run --enable-only govet ./...
    
    # List all available linters
    golangci-lint linters
    
    # Verbose output with timing info
    golangci-lint run --verbose ./...
    

    Configuration

    The recommended .golangci.yml provides a production-ready setup with 33 linters. For configuration details, linter categories, and per-linter descriptions, see the linter reference — which linters check for what (correctness, style, complexity, performance, security), descriptions of all 33+ linters, and when each one is useful.

    Suppressing Lint Warnings

    Use //nolint directives sparingly — fix the root cause first.

    // Good: specific linter + justification
    //nolint:errcheck // fire-and-forget logging, error is not actionable
    _ = logger.Sync()
    
    // Bad: blanket suppression without reason
    //nolint
    _ = logger.Sync()
    

    Rules:

    1. //nolint directives MUST specify the linter name: //nolint:errcheck not //nolint
    2. //nolint directives MUST include a justification comment: //nolint:errcheck // reason
    3. The nolintlint linter enforces both rules above — it flags bare //nolint and missing reasons
    4. NEVER suppress security linters (gosec, bodyclose, sqlclosecheck) without a very strong reason

    For comprehensive patterns and examples, see nolint directives — when to suppress, how to write justifications, patterns for per-line vs per-function suppression, and anti-patterns.

    Development Workflow

    1. Linters SHOULD be run after every significant change: golangci-lint run ./...
    2. Auto-fix what you can: golangci-lint run --fix ./...
    3. Format before committing: golangci-lint fmt ./...
    4. Incremental adoption on legacy code: set issues.new-from-rev in .golangci.yml to only lint new/changed code, then gradually clean up old code

    Makefile targets (recommended):

    lint:
    	golangci-lint run ./...
    
    lint-fix:
    	golangci-lint run --fix ./...
    
    fmt:
    	golangci-lint fmt ./...
    

    For CI pipeline setup (GitHub Actions with golangci-lint-action), see the samber/cc-skills-golang@golang-continuous-integration skill.

    Interpreting Output

    Each issue follows this format:

    path/to/file.go:42:10: message describing the issue (linter-name)
    

    The linter name in parentheses tells you which linter flagged it. Use this to:

    • Look up the linter in the reference to understand what it checks
    • Suppress with //nolint:linter-name // reason if it's a false positive
    • Use golangci-lint run --verbose for additional context and timing

    Common Issues

    Problem Solution
    "deadline exceeded" Set or increase run.timeout in .golangci.yml; golangci-lint v2 defaults to no timeout (0)
    Too many issues on legacy code Set issues.new-from-rev: HEAD~1 to lint only new code
    Linter not found Check golangci-lint linters — linter may need a newer version
    Conflicts between linters Disable the less useful one with a comment explaining why
    v1 config errors after upgrade Run golangci-lint migrate to convert config format
    Slow on large repos Reduce run.concurrency or exclude paths with linters.exclusions.paths / formatters.exclusions.paths

    Parallelizing Legacy Codebase Cleanup

    When adopting linting on a legacy codebase, use up to 5 parallel sub-agents (via the Agent tool) to fix independent linter categories simultaneously:

    • Sub-agent 1: Run golangci-lint run --fix ./... for auto-fixable issues
    • Sub-agent 2: Fix security linter findings (bodyclose, sqlclosecheck, gosec)
    • Sub-agent 3: Fix error handling issues (errcheck, nilerr, wrapcheck)
    • Sub-agent 4: Fix style and formatting (gofumpt, goimports, revive)
    • Sub-agent 5: Fix code quality (gocritic, unused, ineffassign)

    Cross-References

    • → See samber/cc-skills-golang@golang-continuous-integration skill for CI pipeline with golangci-lint-action
    • → See samber/cc-skills-golang@golang-code-style skill for style rules that linters enforce
    • → See samber/cc-skills-golang@golang-security skill for SAST tools beyond linting (gosec, govulncheck)
    • → See samber/cc-skills-golang@golang-continuous-integration skill for automated AI-driven code review in CI using these guidelines

    Reproducido de samber/cc-skills-golang bajo licencia MIT. Leer esta página en markdown.

    Archivos

    5 archivos en el paquete. Solo se lee SKILL.md al activarse — las referencias se cargan si el skill decide que las necesita.

    Antes de instalar

    Requiere los binarios go y golangci-lint instalados (por ejemplo vía brew install golangci-lint).

    Detalles

    Creador
    samber
    Licencia
    MIT
    Recursos incluidos
    referencias
    Código fuente
    Ver SKILL.md

    Etiquetas

    Más de samber/cc-skills-golang

    Este repo incluye 46 skills. Si instalas uno, normalmente ya tienes los demás.

    Benchmarking, profiling y medición de rendimiento en Golang: escribir y comparar benchmarks, perfilar con pprof, analizar con benchstat y detectar regresiones en CI.

    Costo de contexto al activarse
    3.3k tok
    Tamaño del paquete
    10 archivos
    Última actualización
    hace 28 días
    testing qa

    Orquestador de skills de Golang, siempre activo en cualquier tarea de código, revisión, debug o setup: carga las skills más relevantes de samber/cc-skills-golang, a menudo varias a la vez.

    Costo de contexto al activarse
    3.8k tok
    Tamaño del paquete
    4 archivos
    Última actualización
    hace 20 días
    herramientas desarrollo

    Patrones y metodología de optimización de rendimiento en Golang: si hay cuello de botella X, aplica el patrón Y, una vez que profiling o benchmarks ya lo identificaron.

    Costo de contexto al activarse
    2.3k tok
    Tamaño del paquete
    9 archivos
    Última actualización
    el mes pasado
    herramientas desarrollo

    Tests de Golang listos para producción: table-driven, suites y mocks con testify, tests paralelos, fuzzing, fixtures, detección de fugas de goroutines con goleak, snapshot testing, cobertura, tests de integración.

    Costo de contexto al activarse
    4.4k tok
    Tamaño del paquete
    6 archivos
    Última actualización
    el mes pasado
    testing qa

    Inyección de dependencias en Golang con samber/do: contenedores de servicios, gestión de ciclo de vida, scopes, health checks, apagado ordenado y organización en módulos.

    Costo de contexto al activarse
    2.3k tok
    Tamaño del paquete
    4 archivos
    Última actualización
    hace 22 días
    herramientas desarrollo

    Buenas prácticas de seguridad y prevención de vulnerabilidades en Go: inyección, criptografía, filesystem, red, cookies, secretos, memoria y logging.

    Costo de contexto al activarse
    3.5k tok
    Tamaño del paquete
    14 archivos
    Última actualización
    el mes pasado
    seguridad

    Skills relacionados

    Desarrollo de aplicaciones CLI en Go: estructura de comandos, flags, configuración por capas, versión embebida, exit codes, señales, completions y testing con cobra, viper o urfave/cli.

    Costo de contexto al activarse
    2.6k tok
    Tamaño del paquete
    14 archivos
    Última actualización
    hace 3 meses
    herramientas desarrollo

    Convenciones de estilo en Golang: longitud y corte de líneas, declaración de variables, claridad del control de flujo y cuándo los comentarios ayudan u estorban.

    Costo de contexto al activarse
    2.5k tok
    Tamaño del paquete
    3 archivos
    Última actualización
    el mes pasado
    herramientas desarrollo

    Patrones de concurrencia en Go: úsalo al escribir o revisar código concurrente con goroutines, channels, select, locks, sync primitives, errgroup, singleflight, worker pools o pipelines fan-out/fan-in.

    Costo de contexto al activarse
    2.3k tok
    Tamaño del paquete
    5 archivos
    Última actualización
    el mes pasado
    herramientas desarrollo