fix(pre-commit-advisory): pin GOTOOLCHAIN for golang hooks#34
Merged
Conversation
pre-commit builds golang hook envs with whatever go is on PATH; the runner's preinstalled Go lags the repos' targeted 1.26.4, and golangci-lint built on go1.25 refuses to load a config targeting 1.26.4 — broke the advisory job on dispatch#203 / understudy#25 when the repos moved to the upstream golangci/golangci-lint hooks. Derive GOTOOLCHAIN from the repo's highest go.mod directive so the go command auto-provisions the right toolchain; no-op for repos without a go.mod.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Go-repo tooling standardization moved all repos to the upstream
golangci/golangci-lintpre-commit hooks (golangci-lint-fmt+golangci-lint). Those arelanguage: golanghooks — pre-commit builds their env with whatevergois on PATH. This runner's preinstalled Go is 1.25, and a golangci-lint built on go1.25 refuses to load a config targeting go 1.26.4:That broke the advisory job on pinpredict/dispatch#203 and pinpredict/understudy#25 (the repos that call this workflow and have Go hooks). Local runs are unaffected — dev machines pin Go 1.26.4 via asdf.
Fix
A new step derives
GOTOOLCHAINfrom the repo's highestgo.modgodirective (searching nested modules too, skipping vendor/node_modules) before pre-commit runs, so thegocommand auto-provisions the right toolchain for hook builds. Repo-controlled — no hardcoded version here, nothing to bump when repos move Go versions. No-op for repos without a go.mod; baremajor.minordirectives are skipped (can't name a toolchain).language_versionon the hooks was tried first and doesn't work — pre-commit's own Go-download path fails (go install ./...walks into the env's module cache).🤖 Generated with Claude Code