Skip to content
Latchkey

Go staticcheck / golangci-lint failures - Fix in CI

staticcheck and golangci-lint gate CI on lint findings. A failure is either a genuine issue in the code or drift between the linter version/config used locally and in CI.

What this error means

A lint step fails listing findings like SA4006: value never used or errcheck: error return not checked, or it errors loading config. Local runs may pass when a different linter version or .golangci.yml is in effect.

go
pkg/handler.go:42:2: SA4006: this value of err is never used (staticcheck)
pkg/store.go:18:9: Error return value is not checked (errcheck)

Common causes

Genuine lint findings

The linter caught real issues - unused values, unchecked errors, or shadowed variables.

Linter version or config drift

CI runs a different linter version or .golangci.yml than local, so the rule set differs.

How to fix it

Fix the findings

  1. Address each reported issue, then re-run the linter to confirm a clean pass.
Terminal
golangci-lint run ./...

Pin the linter version in CI

  1. Pin a fixed golangci-lint version so local and CI use the same rule set.
.github/workflows/ci.yml
- uses: golangci/golangci-lint-action@v6
  with:
    version: v1.59.1

How to prevent it

  • Pin the linter version in CI and document it for local use.
  • Commit a single .golangci.yml as the source of truth.
  • Run the linter locally before pushing.

Frequently asked questions

What causes "staticcheck / golangci-lint"?
The linter caught real issues - unused values, unchecked errors, or shadowed variables.
How do I fix staticcheck / golangci-lint?
Fix the findings

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card