mirror of
https://github.com/golang/go.git
synced 2026-04-04 02:10:08 +09:00
cmd/go/internal/modload: update WillBeEnabled to check for go.work
In the case where GO111MODULE=auto, we checked whether there was a go.mod file to see if modules would be enabled, but did not check for a go.work file. This brought WillBeEnabled out of sync with Init, which does check for a go.work file. And that resulted with toolchain selection not taking workspaces into account with GO111MODULE=auto. For #76728 Change-Id: I9dd232b2e645b97524ffdf544bcd7e3d6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/753700 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Hongxiang Jiang <hxjiang@golang.org> Reviewed-by: Michael Matloob <matloob@google.com>
This commit is contained in:
committed by
Michael Matloob
parent
dfd2e8027c
commit
7337b4669b
@@ -608,7 +608,7 @@ func (loaderstate *State) WillBeEnabled() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
return FindGoMod(base.Cwd()) != ""
|
||||
return FindGoMod(base.Cwd()) != "" || loaderstate.FindGoWork(base.Cwd()) != ""
|
||||
}
|
||||
|
||||
// FindGoMod returns the name of the go.mod file for this command,
|
||||
|
||||
13
src/cmd/go/testdata/script/gotoolchain_work_issue76728.txt
vendored
Normal file
13
src/cmd/go/testdata/script/gotoolchain_work_issue76728.txt
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# #76728: with GO111MODULE=auto, we didn't switch toolchains properly
|
||||
# in a workspace.
|
||||
|
||||
env GO111MODULE=auto
|
||||
env TESTGO_VERSION=go1.23.0
|
||||
env TESTGO_VERSION_SWITCH=switch
|
||||
|
||||
go version
|
||||
! stdout 1\.23\.0
|
||||
stdout 1\.24\.0
|
||||
|
||||
-- go.work --
|
||||
go 1.24.0
|
||||
Reference in New Issue
Block a user