Skip to content

cmd/go: toolchain selection does not consider the contents of alternate go.mod given to -modfile flag #75440

@ChrisHines

Description

@ChrisHines

Go version

1.24.7

Output of go env in your module/workspace:

set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=0
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\Chris\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=toolchaintrace=1
set GOENV=C:\Users\Chris\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\Chris\AppData\Local\Temp\go-build2159939572=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=C:\Users\Chris\proj\continuous-music\go.mod
set GOMODCACHE=C:\Users\Chris\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Chris\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\Chris\go\pkg\mod\golang.org\toolchain@v0.0.1-go1.24.7.windows-amd64
set GOSUMDB=sum.golang.org
set GOTELEMETRY=on
set GOTELEMETRYDIR=C:\Users\Chris\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=go1.24.7+auto
set GOTOOLDIR=C:\Users\Chris\go\pkg\mod\golang.org\toolchain@v0.0.1-go1.24.7.windows-amd64\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.24.7
set GOWORK=
set PKG_CONFIG=pkg-config

What did you do?

I want to check if the new go vet checks introduced in Go 1.25 find any problems in my code before I upgrade. I would like to perform this check without modifying any version controlled files. Ideally I could run go vet -go=1.25.0 ./... for each of my modules. Since that is not a supported feature at this time I am trying to write a tool to simulate that feature.

The tool attempts to do that by:

  1. Copying the go.mod file to a temporary directory.
  2. Running go get go@1.25 in that directory.
  3. Running go vet -modfile=<tempdir>\go.mod ./...

What did you see happen?

The first two steps work as expected, but the third step fails with the following output. Note I have GODEBUG=toolchaintrace=1 while trying to debug the problem.

go: default toolchain set to go1.24.7 from GOTOOLCHAIN=go1.24.7+auto
go: using go1.24.7 toolchain from cache located at C:\Users\Chris\go\pkg\mod\golang.org\toolchain@v0.0.1-go1.24.7.windows-amd64\bin\go
go: \tmp\go.mod requires go >= 1.25.1 (running go 1.24.7; GOTOOLCHAIN=go1.24.7+auto)

What did you expect to see?

I expected the +auto suffix of the GOTOOLCHAIN setting to allow automatically switching to the go1.25.1 toolchain required by the alternate go.mod file provided to the -modfile flag and the new version of go vet to scan the module for problems.

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions