ci: keep modernize@latest, fetch its toolchain via GOTOOLCHAIN=auto

Replaces the earlier v0.21.0 pin. The modernize analyzer (gopls v0.22+)
requires Go 1.26, which the project doesn't target yet — and bumping the
module to 1.26 isn't viable because the current golangci-lint release is
built with Go 1.25 and refuses to lint a newer target. Instead, let the
modernize task fetch the toolchain it needs on demand via GOTOOLCHAIN=auto
(setup-go pins GOTOOLCHAIN=local in CI), so we stay on the latest analyzer
without touching the module's Go version.

Also bump golang.org/x/image v0.34.0 -> v0.42.0 via `go get -u ./...`.
This commit is contained in:
2026-06-15 17:29:00 +00:00
parent 3b0090c692
commit 0827024e75
3 changed files with 9 additions and 6 deletions
+6 -3
View File
@@ -265,10 +265,13 @@ tasks:
desc: Modernize Go code to use modern idioms
silent: true
aliases: [modern]
env:
# The modernize analyzer (shipped with gopls) may require a newer Go
# toolchain than this project targets. Allow Go to fetch it on demand
# instead of failing under GOTOOLCHAIN=local, which setup-go sets in CI.
GOTOOLCHAIN: auto
cmds:
# Pinned to the v0.21.x line: newer gopls (v0.22+) requires Go 1.26, but
# this project targets Go 1.25 (see go.mod).
- go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.21.0 -fix -test ./...
- go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...
- echo "Code modernized"
# Dependency management