Skip to content

fix(pre-commit-advisory): pin GOTOOLCHAIN for golang hooks#34

Merged
blairham merged 1 commit into
mainfrom
fix/advisory-gotoolchain-for-golang-hooks
Jul 3, 2026
Merged

fix(pre-commit-advisory): pin GOTOOLCHAIN for golang hooks#34
blairham merged 1 commit into
mainfrom
fix/advisory-gotoolchain-for-golang-hooks

Conversation

@blairham

@blairham blairham commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

The Go-repo tooling standardization moved all repos to the upstream golangci/golangci-lint pre-commit hooks (golangci-lint-fmt + golangci-lint). Those are language: golang hooks — pre-commit builds their env with whatever go is 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:

Error: can't load config: the Go language version (go1.25) used to build golangci-lint is lower than the targeted Go version (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 GOTOOLCHAIN from the repo's highest go.mod go directive (searching nested modules too, skipping vendor/node_modules) before pre-commit runs, so the go command 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; bare major.minor directives are skipped (can't name a toolchain).

language_version on 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

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.
@blairham
blairham merged commit e5f77d4 into main Jul 3, 2026
2 checks passed
@blairham
blairham deleted the fix/advisory-gotoolchain-for-golang-hooks branch July 5, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant