fix(make): install golangci-lint via v2 module path so make lint works#600
fix(make): install golangci-lint via v2 module path so make lint works#600
Conversation
The Makefile pinned `github.com/golangci/golangci-lint/cmd/golangci-lint@latest`, which is the v1 module path. Since the v2 release, `@latest` from this path resolves to the last v1.x tag (v1.64.8). The project's `.golangci.yml` uses `version: "2"`, so v1 errors out with: Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2 CI was unaffected because netresearch/.github's `go-check` workflow installs golangci-lint via a path that already targets v2 — only `make lint` was broken locally. - Makefile lint, lint-fix, dev-setup targets: pin `github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest`. - .envrc check_tool hint mirrors the same path so users seeing the "missing" message install the correct version. Verified: `make lint` from a clean state installs v2.12.1 and reports 0 issues against the current `.golangci.yml`. Surfaced by review feedback on PR #597. Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
There was a problem hiding this comment.
Automated approval for maintainer PR
All automated quality gates passed. See SECURITY_CONTROLS.md for compensating controls.
There was a problem hiding this comment.
Pull request overview
This PR fixes local developer linting by updating go install commands to use the github.com/golangci/golangci-lint/v2/... module path, aligning the installed binary with the repository’s .golangci.yml (version: "2") and the CI toolchain.
Changes:
- Switch
make lint,make lint-fix, andmake dev-setupto installgolangci-lintfrom the v2 module path. - Update
.envrc’scheck_toolinstall hint to match the v2 module path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
Makefile |
Updates tool installation lines so make lint/lint-fix/dev-setup install golangci-lint v2 (compatible with .golangci.yml). |
.envrc |
Updates the displayed install hint so developers install the correct golangci-lint v2 module. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #600 +/- ##
==========================================
- Coverage 87.28% 87.21% -0.07%
==========================================
Files 88 88
Lines 10631 10631
==========================================
- Hits 9279 9272 -7
- Misses 1112 1118 +6
- Partials 240 241 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request updates the golangci-lint installation path to use the v2 module in both .envrc and the Makefile. The review feedback recommends pinning the linter to a specific version (v2.12.1) rather than using @latest to ensure consistency between local development and CI environments. Additionally, the feedback suggests standardizing the GOTOOLCHAIN version and ensuring consistent environment variables across all Makefile targets.
|
|
||
| echo -e "${BLUE}🛠️ Checking required tools...${NC}" | ||
| check_tool "golangci-lint" "go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest" | ||
| check_tool "golangci-lint" "go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest" |
There was a problem hiding this comment.
The installation hint uses @latest, which can lead to version drift between local development and the CI environment. Since the PR description mentions that CI runs v2.12.1, it is recommended to pin this version in the hint to ensure consistency across all environments.
check_tool "golangci-lint" "go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.1"
References
- Maintain consistency of tool installation commands across all project configuration files, such as Makefiles and environment setup scripts.
| lint: | ||
| @mkdir -p $(BUILD_PATH)/.tools | ||
| @GOTOOLCHAIN=go1.26.2 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | ||
| @GOTOOLCHAIN=go1.26.2 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest |
There was a problem hiding this comment.
Using @latest for tool installation makes the build non-deterministic and can cause drift between local development and CI. Per the PR description, CI uses v2.12.1, so this version should be pinned here. Additionally, the GOTOOLCHAIN version go1.26.2 is hardcoded and differs from the 1.26 requirement defined in .envrc, which violates the rule of maintaining consistency across configuration files.
@GOTOOLCHAIN=go1.26 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.1
References
- Maintain consistency of tool installation commands across all project configuration files, such as Makefiles and environment setup scripts.
| lint-fix: | ||
| @mkdir -p $(BUILD_PATH)/.tools | ||
| @GOTOOLCHAIN=go1.26.2 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | ||
| @GOTOOLCHAIN=go1.26.2 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest |
There was a problem hiding this comment.
Pinning the linter version to v2.12.1 ensures that the lint-fix target uses the same version as the lint target and the CI environment, preventing unexpected behavior or formatting changes.
@GOTOOLCHAIN=go1.26 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.1
References
- Maintain consistency of tool installation commands across all project configuration files, such as Makefiles and environment setup scripts.
| @echo "🔧 Setting up development environment..." | ||
| @echo "📦 Installing required tools..." | ||
| @go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | ||
| @go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest |
There was a problem hiding this comment.
The dev-setup target should pin the linter version to v2.12.1 for consistency with the lint targets. Furthermore, this command lacks the GOTOOLCHAIN specification used in the lint targets (lines 57 and 64), which could result in the linter being compiled with a different Go version than intended for this project.
@GOTOOLCHAIN=go1.26 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.1
References
- Maintain consistency of tool installation commands across all project configuration files, such as Makefiles and environment setup scripts.



Summary
Makefile's lint, lint-fix, and dev-setup targets pinnedgithub.com/golangci/golangci-lint/cmd/golangci-lint@latest— the v1 module path. Since the v2 release,@latestfrom this path resolves to the last v1.x tag (v1.64.8). The project's.golangci.ymlusesversion: "2", so v1 errors out with:CI was unaffected because
netresearch/.github'sgo-checkworkflow installs golangci-lint via a path that already targets v2. Onlymake lintwas broken locally.Surfaced by a review comment on #597.
Changes
Makefile:57,64,211— three install lines now pingithub.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest..envrc:59—check_toolinstall hint mirrors the v2 path so users seeing the "missing" message install the correct version.Verification
Matches the v2.12.1 that CI runs (
netresearch/.github's go-check installs viago: downloading github.com/golangci/golangci-lint/v2 v2.12.1per the workflow logs).Test plan
make lintfrom clean state installs v2 and runs cleanly