fabianoflorentino/golang-agent-skills

golang-lint

Linting best practices and golangci-lint configuration for Golang projects — running linters, configuring .golangci.yml, suppressing warnings with nolint directives, interpreting lint output, and selecting linters.

Quelltext ansehen
Originales Skill-Dokument

Aus dem Quell-Repository gerendert; Überschriften, Beispiele, Code, Tabellen, Links und Bilder bleiben erhalten.

Linting Go code

Persona: You are a Go code quality engineer. Linting is a first-class part of development, not a post-hoc cleanup: every pattern the tool can catch is a review hour returned to the maintainers.

Modes:

  • Setup — create or tune .golangci.yml, choose linters, wire the pipeline. Sequential.
  • Coding — write new code while a background agent runs golangci-lint run --fix on changed files; surface its output when done. Parallel.
  • Interpret/Fix — read lint output, suppress the rare false positive, clean legacy code. Parallel sub-agents per linter category for a legacy sweep.

When to use: any Golang project that wants a .golangci.yml, any lint warning to interpret or suppress, any linter to choose. CI wiring lives in golang-continuous-integration; style decisions beyond tooling in golang-code-style; SAST (gosec, govulncheck) in golang-security.

The mental model

golangci-lint aggregates 100+ linters under one binary and one config. The file .golangci.yml is the single source of truth for which linters run and how they are wired — agreeing on it is the whole point. See the recommended config shipped with this skill (`assets/.golangci.yml`) as a production baseline.

Quick reference

bash
golangci-lint run ./...               # configured set
golangci-lint run --fix ./...         # auto-fix what it can
golangci-lint fmt ./...               # format (v2+)
golangci-lint run --enable-only govet ./...   # one linter
golangci-lint linters                 # available set
golangci-lint run --verbose ./...     # per-linter timing

Output format

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

The trailing (linter-name) is the key. Look that linter up in `references/linter-reference.md` (what it checks, when it fires, categories) before deciding to fix, suppress, or disable it.

Suppress only with justification

Fix the root cause first. A suppression is an accepted debt entry and must say so:

go
// Fine: named linter + reason
//nolint:errcheck // fire-and-forget logging; error not actionable
_ = logger.Sync()

Three rules, enforced by the nolintlint linter itself:

  1. Name the linter — //nolint:errcheck, never a bare //nolint.
  2. Give a reason on the same comment.
  3. Never suppress security linters (gosec, bodyclose, sqlclosecheck) without a very strong argument.

Choosing and configuring linters

Pick by intent, then prove the choice by running:

ConcernLinters to consider
Correctnessgovet, staticcheck, errcheck, nilerr, ineffassign
Stylegofumpt, revive, misspell, predeclared
Complexitygocritic
Concurrencyparalleltest, thelper
Performanceprealloc, moved by cost-governed reviews
Securitygosec, bodyclose, sqlclosecheck (see golang-security)

Disabled-by-default linters must be deliberately enabled in .golangci.yml; document why in a comment next to each.

Common issues

ProblemSolution
deadline exceededRaise run.timeout; v2 defaults to no timeout
Legacy floodissues.new-from-rev: HEAD~1 — lint only new code, then slowly widen
Linter not foundVersion too old — golangci-lint linters to confirm
Linters conflictDisable the weaker one with a reason in the config
v1 config errorsgolangci-lint migrate converts the format
Slow on large reposTune run.concurrency, exclude paths

Workflow

Run golangci-lint run ./... after every significant change; --fix what it hands back; format before commit (golangci-lint fmt ./...). Makefile targets keep it one word:

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

Parallel legacy cleanup

Adopting linting on a legacy tree? Fan out one sub-agent per category so the categories fix concurrently: (1) auto-fix, (2) security linters, (3) error handling (errcheck, wrapcheck, nilerr), (4) style/formatting (gofumpt, goimports, revive), (5) code quality (gocritic, unused, ineffassign).

Cross-references

  • golang-continuous-integration — lint CI step (golangci-lint-action) and AI review gating.
  • golang-code-style — the style rules linters enforce.
  • golang-security — SAST beyond linting (gosec, govulncheck).
  • golang-testing — test-focused linters (thelper, paralleltest, testifylint).
  • golang-naming — conventions that revive/predeclared/errname check.
aus demselben Repository

Weitere Skills

Alle Skills
fabianoflorentino
Community

golang-design-patterns

Idiomatic Golang design patterns — functional options, constructor APIs, init() and global-state avoidance, enums, panic vs error decisions, resource management and lifecycle, graceful shutdown, timeouts and retries, streaming and iterators, and architecture styles (clean, hexagonal, DDD, flat). Apply when choosing between architectural patterns, implementing functional options, designing constructor APIs, setting up graceful shutdown, applying resilience patterns, or asking which idiomatic Go pattern fits a specific problem. Not for wiring a DI container or comparing DI libraries (→ See fabianoflorentino/golang-agent-skills@golang-dependency-injection skill), nor for error wrapping, errors.Is/As, or logging mechanics (→ See fabianoflorentino/golang-agent-skills@golang-error-handling skill).

Installationen
1
GitHub Stars
0
Aktualisiert
14. Sept.
fabianoflorentino
Community

golang-google-wire

Compile-time dependency injection in Golang using google/wire — wire.NewSet, wire.Build, wire.Bind (interface→concrete), wire.Struct, wire.Value, wire.InterfaceValue, wire.FieldsOf, cleanup functions, //go:build wireinject injector files, and generated wiregen.go. Apply when using or adopting google/wire, when the codebase imports github.com/google/wire, or when wiring an application graph at compile time via wire.Build. For runtime DI with reflection, see fabianoflorentino/golang-agent-skills@golang-uber-dig skill.

Installationen
1
GitHub Stars
0
Aktualisiert
14. Sept.
fabianoflorentino
Community

golang-modernize

Modernize Golang code to use recent language features, standard library improvements, and idiomatic patterns. Use when reviewing Go code with old-style patterns, when encountering a deprecation warning, or when the user asks for modernization, a Go version upgrade (e.g. to Go 1.27), or a CI/tooling refresh. Not for structural refactors, extracting functions, or moving code between packages (→ See fabianoflorentino/golang-agent-skills@golang-refactoring skill).

Installationen
1
GitHub Stars
0
Aktualisiert
14. Sept.
fabianoflorentino
Community

golang-pitfalls-concurrency-foundations

Golang concurrency foundations — concurrency vs parallelism, thinking concurrency is always faster, channels vs mutexes, not understanding race problems (data race vs race condition), not understanding workload types (CPU vs I/O bound, GOMAXPROCS), and misunderstanding Go contexts. Distilled from mistakes 55-60 of 100 Go Mistakes and How to Avoid Them. Apply when reasoning about basic Golang concurrency, goroutines, and context usage.

Installationen
1
GitHub Stars
0
Aktualisiert
14. Sept.