Skip to content
Latchkey

golangci/golangci-lint-action

Run golangci-lint with line-attached annotations, caching, and only-new-issues PR mode.

Official actionCategory: Code Quality & LintingLatest v9View on GitHub

What it does

golangci/golangci-lint-action is the official way to run golangci-lint in GitHub Actions. It installs the requested version, runs it with caching, and attaches issues to the changed lines.

On pull requests it can restrict output to newly introduced issues, which makes adopting the linter on an existing codebase practical.

Usage

workflow (.yml)
permissions:
  contents: read
steps:
  - uses: actions/checkout@v4
  - uses: actions/setup-go@v5
    with:
      go-version: stable
  - uses: golangci/golangci-lint-action@v9
    with:
      version: latest
      only-new-issues: true

Inputs

InputDescriptionDefaultRequired
versionThe version of golangci-lint to use, e.g. v2.3, v2.3.4, or latest.-No
only-new-issuesOn a pull request, output only newly found issues.falseNo
working-directorygolangci-lint working directory. The default is the project root.-No
argsgolangci-lint command line arguments.-No
install-modeThe mode to install golangci-lint: 'binary', 'goinstall', or 'none'.binaryNo
verifyVerify the configuration file against the JSONSchema.trueNo
skip-cacheCompletely disable all caching functionality.falseNo

Notes

Run actions/setup-go before this action, golangci-lint needs a working Go toolchain that matches your module.

Recent majors of the action ship golangci-lint v2; a v1-format .golangci.yml fails the built-in config verification. Migrate the config or pin an older version.

Common errors

  • Issues reported by the typecheck linter mean the code did not compile in CI, usually a Go version mismatch with setup-go or missing module downloads, not a real lint finding.
  • A config verification failure right at startup means .golangci.yml does not match the JSONSchema for the installed golangci-lint version (commonly a v1 config running under v2). Migrate the config or set verify: false while transitioning.

Security and pinning

  • The action only needs contents: read (plus the default token for PR-patch fetching via github-token). Pin to a commit SHA for supply-chain safety.

Alternatives and related

Frequently asked questions

How do I lint only the code changed in a PR?
Set only-new-issues: true. The action fetches the PR patch and filters findings to lines introduced by the PR, so pre-existing issues do not block the merge.
Running golangci/golangci-lint-action? Run it on Latchkey managed runners - self-healing and caching included. Start free → 30-day trial · No credit card