aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/load.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2023-05-25 17:07:26 -0400
committerGopher Robot <gobot@golang.org>2023-06-02 23:07:08 +0000
commit77786d90fae21f526caaddd23c887a2a7233a299 (patch)
treec781e5ff1abe4e259638e342ea7e00d5a374bf3f /src/cmd/go/internal/modload/load.go
parentc292a74c389aed9cab01d435a8f8cb4bfb087544 (diff)
downloadgo-77786d90fae21f526caaddd23c887a2a7233a299.tar.gz
go-77786d90fae21f526caaddd23c887a2a7233a299.zip
cmd/go: adjust pruning and switch toolchains if needed when go get changes go version
When we do 'go get', the Go version can change now. That means we need to do the pruning conversions that until now have only been necessary in go mod tidy -go=version. We may also need to upgrade the toolchain in order to load enough o the module graph to finish the edit, so we should let a TooNewError bubble up to the caller instead of trying to downgrade the affected module to avoid the error. Revised from CL 498120. For #57001. Change-Id: Ic8994737eca4ed61ccc093a69e46f5a6caa8be87 Reviewed-on: https://go-review.googlesource.com/c/go/+/498267 Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modload/load.go')
-rw-r--r--src/cmd/go/internal/modload/load.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go
index a96ce0283d..5384d753bf 100644
--- a/src/cmd/go/internal/modload/load.go
+++ b/src/cmd/go/internal/modload/load.go
@@ -1013,6 +1013,8 @@ func loadFromRoots(ctx context.Context, params loaderParams) *loader {
ld.errorf("go: go.mod file indicates go %s, but maximum version supported by tidy is %s\n", ld.GoVersion, gover.Local())
base.ExitIfErrors()
}
+ } else {
+ ld.requirements = overrideRoots(ctx, ld.requirements, []module.Version{{Path: "go", Version: ld.GoVersion}})
}
if ld.Tidy {