cmd/go: compile error for toolchain default in go.mod, removed by mod tidy #73127
Labels
BugReport
Issues describing a possible bug in the Go implementation.
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Go version
go version go1.24.1 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I'm following go.mod specification which allows to disable automatic toolchain switching with
toolchain default
directive.I'm using following minimal example to reproduce the issue:
main.go
go.mod
What did you see happen?
Attempt to build or run it produces requires
go mod tidy
and ends up with following error:But running
go mod tidy
stripstoolchain
directive and leaves me with following go.modWhat did you expect to see?
I expect
go build
andgo run
to not have false positive about "dirty" go.mod and run it with original go.mod without any issue. Also I expectgo mod tidy
to respect specification and preserve directives I've set.The text was updated successfully, but these errors were encountered: