-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: make 'go get' match patterns against packages, not modules
This is a follow-up to CL 174099, fixing an important TODO. The 'go help modget' documentation will be clarified in anotehr CL, pending further discussion. When invoked without -m, 'go get' will no longer match arguments containing "..." against module paths. If a module's path matches a pattern but no packages within the module match the pattern, the module should not be upgraded. For example, if golang.org/x/tools/playground and golang.org/x/tools are separate modules, and only golang.org/x/tools is in the build list, 'go get golang.org/x/tools/playground/...' should add golang.org/x/tools/playground to the build list and leave golang.org/x/tools alone. Updates #26902 Change-Id: I2bd18c7950db1aa7bd8527210c1baf2c7d174375 Reviewed-on: https://go-review.googlesource.com/c/go/+/176578 Run-TryBot: Jay Conrod <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
- Loading branch information
Jay Conrod
committed
May 13, 2019
1 parent
ed7a92b
commit 71be83e
Showing
6 changed files
with
90 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Written by hand. | ||
Test case for nested modules without an explicit relationship. | ||
This is nested below the top-level module. | ||
|
||
-- .mod -- | ||
module example.com/nest/sub | ||
-- .info -- | ||
{"Version": "v1.0.0"} | ||
-- go.mod -- | ||
module example.com/nest/sub | ||
-- y/y.go -- | ||
package y |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Written by hand. | ||
Test case for nested modules without an explicit relationship. | ||
This is the top-level module. | ||
|
||
-- .mod -- | ||
module example.com/nest | ||
-- .info -- | ||
{"Version": "v1.0.0"} | ||
-- go.mod -- | ||
module example.com/nest | ||
-- sub/x/x.go -- | ||
package x |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Written by hand. | ||
Test case for nested modules without an explicit relationship. | ||
This is the top-level module. | ||
|
||
-- .mod -- | ||
module example.com/nest | ||
-- .info -- | ||
{"Version": "v1.1.0"} | ||
-- go.mod -- | ||
module example.com/nest | ||
-- sub/x/x.go -- | ||
package x |
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 |
---|---|---|
|
@@ -16,9 +16,10 @@ stderr '^go get [email protected]: can.t get a specific version of the main module$' | |
! go get -d rsc.io/[email protected] | ||
stderr '^go get rsc.io/[email protected]: can.t query specific version for package rsc.io/x in the main module \(rsc.io\)$' | ||
|
||
# TODO: upgrading a package pattern not contained in the main module should not | ||
# Upgrading a package pattern not contained in the main module should not | ||
# attempt to upgrade the main module. | ||
! go get rsc.io/quote/[email protected] | ||
go get rsc.io/quote/[email protected] | ||
grep 'rsc.io/quote v1.5.1' go.mod | ||
|
||
-- go.mod.orig -- | ||
module rsc.io | ||
|
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 |
---|---|---|
|
@@ -22,6 +22,14 @@ stderr 'go get rsc.io/quote/x...: module rsc.io/quote@latest \(v1.5.2\) found, b | |
stderr 'go get rsc.io/quote/x/...: module rsc.io/quote@latest \(v1.5.2\) found, but does not contain packages matching rsc.io/quote/x/...' | ||
! grep 'require rsc.io/quote' go.mod | ||
|
||
# If a pattern matches no packages within a module, the module should not | ||
# be upgraded, even if the module path matches the pattern. | ||
cp go.mod.orig go.mod | ||
go mod edit -require example.com/[email protected] | ||
go get example.com/nest/sub/y... | ||
grep 'example.com/nest/sub v1.0.0' go.mod | ||
grep 'example.com/nest v1.0.0' go.mod | ||
|
||
-- go.mod.orig -- | ||
module m | ||
|
||
|