]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/go: smooth out upgrade paths for lazy loading
authorBryan C. Mills <bcmills@google.com>
Thu, 29 Apr 2021 13:27:40 +0000 (09:27 -0400)
committerBryan C. Mills <bcmills@google.com>
Fri, 30 Apr 2021 18:06:46 +0000 (18:06 +0000)
commit7dedc237c528fa268934a8ed81c01fc65db5f800
treee86aba58db59d7d67ecfab1b3e23859366c234b8
parent0e315ad79ae388eedb03dce27101c40b29292e2a
cmd/go: smooth out upgrade paths for lazy loading

This change adds two possible upgrade paths for lazy loading:

1. Run 'go mod tidy -go=1.17'.

2. Starting in a module with no existing 'go' directive,
   run any 'go' command that updates the go.mod file.

In the latter case, commands other than 'go mod tidy'
may leave the go.mod file *very* untidy if it had non-trivial
dependencies. (The 'go' invocation will promote all
implicit eager dependencies to explicit lazy ones,
which preserves the original module graph — most of which is
not actually relevant.)

'go mod tidy -go=1.17' can be used to enable lazy loading without
accidentally downgrading existing transitive dependencies.

'go mod tidy -go=1.16' can be used to disable lazy loading and clear
away redundant roots in a single step (if reducing the go version), or
to prune away dependencies of tests-of-external-tests (if increasing
the go version).

'go mod tidy -go=1.15' can be used to add dependencies of
tests-of-external-tests, although there isn't much point to that.

DO NOT MERGE

This change still needs an explicit test and a release note.

Fixes #45094
For #36460

Change-Id: I68f057e39489dfd6a667cd11dc1e320c1ee1aec1
Reviewed-on: https://go-review.googlesource.com/c/go/+/315210
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
14 files changed:
doc/go1.17.html
src/cmd/go/alldocs.go
src/cmd/go/internal/modcmd/tidy.go
src/cmd/go/internal/modload/build.go
src/cmd/go/internal/modload/buildlist.go
src/cmd/go/internal/modload/edit.go
src/cmd/go/internal/modload/init.go
src/cmd/go/internal/modload/list.go
src/cmd/go/internal/modload/load.go
src/cmd/go/internal/modload/modfile.go
src/cmd/go/testdata/script/mod_go_version_missing.txt
src/cmd/go/testdata/script/mod_load_replace_mismatch.txt
src/cmd/go/testdata/script/mod_retention.txt
src/cmd/go/testdata/script/mod_tidy_version.txt [new file with mode: 0644]