mirror of
https://github.com/golang/go.git
synced 2026-04-03 17:59:55 +09:00
cmd/go: provide concise user message to use - go work use
Fixes #64007 Change-Id: Ia1de6b33b2a531545984351e4453aa5d97b16953 Reviewed-on: https://go-review.googlesource.com/c/go/+/589815 Reviewed-by: Michael Matloob <matloob@golang.org> Auto-Submit: Michael Matloob <matloob@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
@@ -1156,8 +1156,8 @@ func errWorkTooOld(gomod string, wf *modfile.WorkFile, goVers string) error {
|
||||
// even when it doesn't list any version.
|
||||
verb = "implicitly requires"
|
||||
}
|
||||
return fmt.Errorf("module %s listed in go.work file requires go >= %s, but go.work %s go %s; to update it:\n\tgo work use",
|
||||
base.ShortPath(filepath.Dir(gomod)), goVers, verb, gover.FromGoWork(wf))
|
||||
return fmt.Errorf("module %s listed in go.work file requires go >= %s, but go.work %s go %s; to download and use go %s:\n\tgo work use",
|
||||
base.ShortPath(filepath.Dir(gomod)), goVers, verb, gover.FromGoWork(wf), goVers)
|
||||
}
|
||||
|
||||
// CheckReservedModulePath checks whether the module path is a reserved module path
|
||||
|
||||
@@ -8,7 +8,7 @@ stderr '^go: go.mod requires go >= 1.99999 \(running go 1\..+\)$'
|
||||
# go.mod referenced from go.work too new
|
||||
cp go.work.old go.work
|
||||
! go build .
|
||||
stderr '^go: module . listed in go.work file requires go >= 1.99999, but go.work lists go 1.10; to update it:\n\tgo work use$'
|
||||
stderr '^go: module . listed in go.work file requires go >= 1.99999, but go.work lists go 1.10; to download and use go 1.99999:\n\tgo work use$'
|
||||
|
||||
! go work sync
|
||||
stderr '^go: cannot load module . listed in go.work file: go.mod requires go >= 1.99999 \(running go 1\..+\)$'
|
||||
|
||||
@@ -7,7 +7,7 @@ env TESTGO_VERSION=go1.21.1
|
||||
env TESTGO_VERSION_SWITCH=switch
|
||||
cp go.work go.work.orig
|
||||
! go list
|
||||
stderr '^go: module . listed in go.work file requires go >= 1.21.2, but go.work lists go 1.21.1; to update it:\n\tgo work use$'
|
||||
stderr '^go: module . listed in go.work file requires go >= 1.21.2, but go.work lists go 1.21.1; to download and use go 1.21.2:\n\tgo work use$'
|
||||
go work use
|
||||
go list
|
||||
|
||||
@@ -16,7 +16,7 @@ env TESTGO_VERSION=go1.21.2
|
||||
env TESTGO_VERSION_SWITCH=switch
|
||||
cp go.work.orig go.work
|
||||
! go list
|
||||
stderr '^go: module . listed in go.work file requires go >= 1.21.2, but go.work lists go 1.21.1; to update it:\n\tgo work use$'
|
||||
stderr '^go: module . listed in go.work file requires go >= 1.21.2, but go.work lists go 1.21.1; to download and use go 1.21.2:\n\tgo work use$'
|
||||
|
||||
# go work use fixes the problem.
|
||||
go work use
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# go directive in a go.work file so 1.18 is implicitly required.
|
||||
|
||||
! go list
|
||||
stderr 'go: module . listed in go.work file requires go >= 1.21, but go.work implicitly requires go 1.18; to update it:\s+go work use'
|
||||
stderr 'go: module . listed in go.work file requires go >= 1.21, but go.work implicitly requires go 1.18; to download and use go 1.21:\s+go work use'
|
||||
|
||||
go work use
|
||||
go list
|
||||
|
||||
Reference in New Issue
Block a user