-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change activates the dormant “lazy loading” codepaths added in CL 265777 and its predecessors. Dependencies of modules that declare 'go 1.17' or higher are loaded lazily, and the dependencies in the go.mod file maintain additional invariants to support more efficient lazy loading for downstream dependent modules. See https://golang.org/design/36460-lazy-module-loading for the detailed design. For #36460 Change-Id: Ic12ee7842aef9580357fcf8909d87654fcb2ad12 Reviewed-on: https://go-review.googlesource.com/c/go/+/314634 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
- Loading branch information
Bryan C. Mills
committed
Apr 30, 2021
1 parent
2bd3e48
commit 9a81702
Showing
16 changed files
with
396 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,9 +67,9 @@ cd tmp | |
go mod init tmp | ||
go mod edit -require=rsc.io/[email protected] | ||
! go install -mod=readonly $GOPATH/pkg/mod/rsc.io/[email protected] | ||
stderr '^go: rsc.io/[email protected]: missing go.sum entry; to add it:\n\tgo mod download rsc.io/fortune$' | ||
stderr '^rsc.io/[email protected]: missing go.sum entry; to add it:\n\tgo mod download rsc.io/fortune$' | ||
! go install -mod=readonly ../../pkg/mod/rsc.io/[email protected] | ||
stderr '^go: rsc.io/[email protected]: missing go.sum entry; to add it:\n\tgo mod download rsc.io/fortune$' | ||
stderr '^rsc.io/[email protected]: missing go.sum entry; to add it:\n\tgo mod download rsc.io/fortune$' | ||
go get -d rsc.io/[email protected] | ||
go install -mod=readonly $GOPATH/pkg/mod/rsc.io/[email protected] | ||
exists $GOPATH/bin/fortune$GOEXE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# This test illustrates the interaction between lazy loading and downgrading in | ||
# 'go get. | ||
# 'go get'. | ||
|
||
# The package import graph used in this test looks like: | ||
# | ||
|
@@ -46,7 +46,7 @@ go list -m all | |
# outside of the deepening scan should not affect the downgrade. | ||
|
||
cp go.mod.orig go.mod | ||
go mod edit -go=1.16 | ||
go mod edit -go=1.17 | ||
|
||
go list -m all | ||
stdout '^example.com/a v0.1.0 ' | ||
|
@@ -59,12 +59,50 @@ stdout '^example.com/a v0.1.0 ' | |
stdout '^example.com/b v0.2.0 ' | ||
stdout '^example.com/c v0.1.0 ' | ||
|
||
# At this point, b.2 is still an explicit root, so its dependency on c | ||
# is still tracked, and it will still be downgraded away if we remove c. | ||
# ('go get' never makes a root into a non-root. Only 'go mod tidy' does that.) | ||
|
||
go get -d example.com/c@none | ||
go list -m all | ||
! stdout '^example.com/a ' # TODO(#36460): example.com/a v0.1.0 | ||
! stdout '^example.com/b ' # TODO(#36460): example.com/b v0.1.0 | ||
! stdout '^example.com/a ' | ||
! stdout '^example.com/b ' | ||
! stdout '^example.com/c ' | ||
|
||
|
||
# This time, we drop the explicit 'b' root by downgrading it to v0.1.0 | ||
# (the version required by a.1) and running 'go mod tidy'. | ||
# It is still selected at v0.1.0 (as a dependency of a), | ||
# but its dependency on c is now pruned from the module graph, so it doesn't | ||
# result in any downgrades to b or a if we run 'go get c@none'. | ||
|
||
cp go.mod.orig go.mod | ||
go mod edit -go=1.17 | ||
|
||
go list -m all | ||
stdout '^example.com/a v0.1.0 ' | ||
stdout '^example.com/b v0.3.0 ' | ||
stdout '^example.com/c v0.2.0 ' | ||
|
||
go get -d example.com/[email protected] example.com/[email protected] | ||
go list -m all | ||
stdout '^example.com/a v0.1.0 ' | ||
stdout '^example.com/b v0.1.0 ' | ||
stdout '^example.com/c v0.1.0 ' | ||
|
||
go mod tidy | ||
go list -m all | ||
stdout '^example.com/a v0.1.0 ' | ||
stdout '^example.com/b v0.1.0 ' | ||
! stdout '^example.com/c ' | ||
|
||
go get -d example.com/c@none | ||
go list -m all | ||
stdout '^example.com/a v0.1.0' | ||
stdout '^example.com/b v0.1.0' | ||
! stdout '^example.com/c ' | ||
|
||
|
||
-- go.mod -- | ||
module example.com/lazy | ||
|
||
|
@@ -91,7 +129,7 @@ import _ "example.com/a" | |
-- a/go.mod -- | ||
module example.com/a | ||
|
||
go 1.15 | ||
go 1.17 | ||
|
||
require example.com/b v0.1.0 | ||
-- a/a.go -- | ||
|
@@ -104,7 +142,7 @@ import _ "example.com/b" | |
-- b1/go.mod -- | ||
module example.com/b | ||
|
||
go 1.15 | ||
go 1.17 | ||
|
||
require example.com/c v0.1.0 | ||
-- b1/b.go -- | ||
|
@@ -116,7 +154,7 @@ import _ "example.com/c" | |
-- b2/go.mod -- | ||
module example.com/b | ||
|
||
go 1.15 | ||
go 1.17 | ||
|
||
require example.com/c v0.1.0 | ||
-- b2/b.go -- | ||
|
@@ -128,7 +166,7 @@ import _ "example.com/c" | |
-- b3/go.mod -- | ||
module example.com/b | ||
|
||
go 1.15 | ||
go 1.17 | ||
|
||
require example.com/c v0.2.0 | ||
-- b3/b.go -- | ||
|
@@ -140,6 +178,6 @@ import _ "example.com/c" | |
-- c/go.mod -- | ||
module example.com/c | ||
|
||
go 1.15 | ||
go 1.17 | ||
-- c/c.go -- | ||
package c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.