cmd/go: removed unused code in toolchain.Exec

This change removes the unused module loader state in the function
`toolchain.Exec`.

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: I8935f14447db4669457becc5a96db7f45132772f
Reviewed-on: https://go-review.googlesource.com/c/go/+/709980
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
Ian Alexander 2025-10-01 17:42:38 -04:00
parent 180c07e2c1
commit a6929cf4a7

View file

@ -285,6 +285,7 @@ func Select() {
counterSelectExec.Inc()
Exec(moduleLoaderState, gotoolchain)
panic("unreachable")
}
var counterSelectExec = counter.New("go/toolchain/select-exec")
@ -352,12 +353,6 @@ func Exec(s *modload.State, gotoolchain string) {
base.Fatalf("cannot find %q in PATH", gotoolchain)
}
// Set up modules without an explicit go.mod, to download distribution.
s.Reset()
s.ForceUseModules = true
s.RootMode = modload.NoRoot
modload.Init(s)
// Download and unpack toolchain module into module cache.
// Note that multiple go commands might be doing this at the same time,
// and that's OK: the module cache handles that case correctly.