golangci-lint fails in GitHub Actions with typecheck errors like can't load fmt
can't load fmtShort answer
golangci-lint only supports Go versions up to the one it was compiled with. If your go.mod or setup-go uses a newer Go than your linter build, it fails to load even the standard library. Update the linter version in the action and install Go with setup-go before it.
Fix it fast
1Find out which cause you have
Print the Go version the linter was built with and compare it with the Go version your job installs.
golangci-lint version go version2Match what you see, then jump to its fix
- 1
The failure started after you raised go.mod or setup-go to a newer Go, and the action still pins an old versionThe pinned golangci-lint was built with an older Go than the project usesFix - 2
The job has checkout and the lint action only; the runner's default Go is usedThere is no actions/setup-go step before the lint actionFix
- 1
What does the error look like?
can't load fmttypecheck errors that stop all other golangci-lint reportsthe same code lints fine locally with a newer golangci-lint
Cause 1 of 2
The pinned golangci-lint was built with an older Go than the project uses
1Check
The FAQ states that golangci-lint supports Go versions lower than or equal to the one used to compile it. Check the pinned version in the workflow.
grep -n "golangci\|version\|go-version" .github/workflows/*.yml2Fix
Raise the version input to a release built with a Go at least as new as the project's, or use latest.
- uses: golangci/golangci-lint-action@v9
with:
version: latest3Verify
Re-run the job; typecheck errors are gone.
golangci-lint run ./...Confirmed by golangci-lint.run
Cause 2 of 2
There is no actions/setup-go step before the lint action
1Check
The action needs an explicit actions/setup-go step before it runs.
grep -n "setup-go" .github/workflows/*.yml2Fix
Add setup-go with the Go version your module needs, ahead of the lint step.
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: stable
- uses: golangci/golangci-lint-action@v9
with:
version: latest3Verify
The job logs the Go version you chose, and lint runs.
go versionConfirmed by github.com
How do I stop it coming back?
- Pin a minor version such as v2.13 for repeatable runs, and raise it whenever you raise the Go version.
- Run golangci-lint version in a CI step so the pair of versions is always in the log.
- Read typecheck errors first; golangci-lint cannot produce other reports while they exist.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Servers
Docker push to Artifact Registry fails from GitHub Actions with a permission error
Permission 'artifactregistry.repositories.uploadArtifacts' denied on resource
The identity your workflow authenticates as lacks the permission artifactregistry.repositories.uploadArtifacts on the target repository.
4 causes, each with a fixServers
docker pull or push to ghcr.io fails with 'denied'
Error response from daemon: denied
ghcr.io refuses a pull or push when Docker is not logged in, when the token lacks the package scope, or when the workflow's GITHUB_TOKEN has no packages permission or no access to that package.
4 causes, each with a fixServers
git says it could not read Username for https://github.com in a build or CI job
fatal: could not read Username for 'https://github.com': No such device or address
Git asked for HTTPS credentials and there was no terminal to ask on, so it gave up.
3 causes, each with a fixServers
upload-artifact fails because the artifact storage quota is full
Create Artifact Container failed: Artifact storage quota has been hit. Unable to upload any new artifacts
Uploads fail when your account's shared artifact storage is used up.
3 causes, each with a fixServers
configure-aws-credentials says no OpenID Connect provider exists for GitHub
No OpenIDConnect provider found in your account for https://token.actions.githubusercontent.com
AWS has no IAM identity provider for GitHub's token issuer in the account that holds the role.
3 causes, each with a fixServers
A local composite action in GitHub Actions cannot be found
The action folder is in the repository but the runner reports that its action.yml cannot be found
A local action is read from the checked-out repository.
3 causes, each with a fix