]> Cypherpunks repositories - gostls13.git/commit
cmd/go: don't write own toolchain line when updating go line
authorMichael Matloob <matloob@golang.org>
Mon, 10 Mar 2025 17:32:23 +0000 (13:32 -0400)
committerMichael Matloob <matloob@golang.org>
Wed, 12 Mar 2025 18:44:56 +0000 (11:44 -0700)
commita68bf75d3402412a1946fe1df67f57ca923f1507
treedc5f6ba11c1e39cdd0e71cde8165a713946f03a1
parent485480faaac82e4179f7b56c1c370020157f25a8
cmd/go: don't write own toolchain line when updating go line

The Go command had a behavior of writing its own toolchain name when
updating the go line in a go.mod (for example when a user runs go get
go@version). This behavior was often undesirable and the toolchain line
was often removed by users before checking in go.mod files (including in
the x/ repos). It also led to user confusion.

This change removes that behavior. A toolchain line will not be added if
one wasn't present before. The toolchain line can still be removed
though: the toolchain line must be at least the go version, so if the go
version is increased above the toolchain version, the toolchain version
will be bumped up to that go version. Then the toolchain line will then
be dropped because go <version> implies toolchain <version>.

Making this change slightly hurts reproducability because future go
commands run on the go.mod file may be run with a different toolchain
than the one that used it, but that doesn't seem to be worth the
confusion the behavior resulted in.

We expect this change will not have negative consequences, but it could
be possible, and we would like to hear from any users that depended on
the previous behavior in case we need to roll it back before the
release.

Fixes #65847

Change-Id: Id795b7f762e4f90ba0fa8c7935d03f32dfc8590e
Reviewed-on: https://go-review.googlesource.com/c/go/+/656835
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/go/internal/modload/init.go
src/cmd/go/testdata/script/gotoolchain_modcmds.txt
src/cmd/go/testdata/script/mod_download_exec_toolchain.txt
src/cmd/go/testdata/script/mod_get_exec_toolchain.txt
src/cmd/go/testdata/script/mod_get_toolchain.txt
src/cmd/go/testdata/script/mod_import_toolchain.txt
src/cmd/go/testdata/script/mod_tidy_version.txt
src/cmd/go/testdata/script/mod_toolchain.txt
src/cmd/go/testdata/script/work_get_toolchain.txt
src/cmd/go/testdata/script/work_sync_toolchain.txt
src/cmd/go/testdata/script/work_use_toolchain.txt