Fixing golangci-lint Go Version Mismatch
When encountering the following golangci-lint error in GitHub Actions or locally:
1run golangci-lint
2 Running [/home/runner/golangci-lint-1.64.8-linux-amd64/golangci-lint config path] in [/home/runner/work/fork-mdtohtml/fork-mdtohtml] ...
3 Running [/home/runner/golangci-lint-1.64.8-linux-amd64/golangci-lint run] in [/home/runner/work/fork-mdtohtml/fork-mdtohtml] ...
4 Error: can't load config: the Go language version (go1.24) used to build golangci-lint is lower than the targeted Go version (1.25.0)
5 Failed executing command with error: can't load config: the Go language version (go1.24) used to build golangci-lint is lower than the targeted Go version (1.25.0)
6
7 Error: golangci-lint exit with code 3
8 Ran golangci-lint in 85ms
This specific error means you must perform the following steps to properly resolve it:
- Delete configuration files: Delete
golangci-lint.confor other old configuration files. - Update dependencies: Update
golangci-lintandgolangci-lint-actionto the latest versions. Use external references to find the latest versions, do not default to old versions. - Upgrade Go everywhere: Upgrade Go across the entire repository to match the required version. Ensure GitHub Actions are using
go-version-file: go.mod(or similar) to keep versions in sync. - Resolve lint issues in a loop: Rerun
golangci-lintensuring it uses the updated version. Do not create a new config file. Instead, attempt to solve all issues iteratively in a loop (resolving a couple of issues each loop) until done. - Format code: Run
go fmt ./...on the codebase. - Submit: Once all steps are complete and the build passes, submit the changes.
Example Correct GitHub Action Configuration
Ensure your workflow uses the latest action versions and syncs the Go version from go.mod:
1 - uses: actions/checkout@v6
2 - uses: actions/setup-go@v6
3 with:
4 go-version-file: go.mod
5 - name: golangci-lint
6 uses: golangci/golangci-lint-action@v9
7 with:
8 version: latest
This procedure ensures that you do not fall back to old and incompatible versions of Go, golangci-lint, and golangci-lint-action.