-
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.
cmd/go: make hints in error messages more consistent
* All commands the user can run to fix the problem now appear alone on a separate line after a tab. * Removed -d from 'go get' commands. * Replaced 'go mod tidy' with 'go mod download $modpath' when a package might be provided by a module missing a sum. * Errors about 'path@version' syntax are more explicit. Fixes #29415 Fixes #42087 Fixes #43430 Fixes #43523 Change-Id: I4427c2c4506a727a2c727d652fd2d506bb134d3b Reviewed-on: https://go-review.googlesource.com/c/go/+/282121 Trust: Jay Conrod <[email protected]> Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
- Loading branch information
Jay Conrod
committed
Jan 8, 2021
1 parent
25886cf
commit 6192b98
Showing
17 changed files
with
42 additions
and
36 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
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 |
---|---|---|
|
@@ -6,17 +6,21 @@ cp go.mod.orig go.mod | |
go list -m indirect-with-pkg | ||
stdout '^indirect-with-pkg v1.0.0 => ./indirect-with-pkg$' | ||
! go list ./use-indirect | ||
stderr '^go: m/use-indirect: package indirect-with-pkg imported from implicitly required module; try ''go get -d m/use-indirect'' to add missing requirements$' | ||
stderr '^go: m/use-indirect: package indirect-with-pkg imported from implicitly required module; to add missing requirements, run:\n\tgo get [email protected]$' | ||
|
||
# We can promote the implicit requirement by getting the importing package, | ||
# as hinted. | ||
# We can promote the implicit requirement by getting the importing package. | ||
# NOTE: the hint recommends getting the imported package (tested below) since | ||
# it's more obvious and doesn't require -d. However, that adds an '// indirect' | ||
# comment on the requirement. | ||
go get -d m/use-indirect | ||
cmp go.mod go.mod.use | ||
cp go.mod.orig go.mod | ||
|
||
# We can also promote implicit requirements using 'go get' on them, or their | ||
# packages. This gives us "// indirect" requirements, since 'go get' doesn't | ||
# know they're needed by the main module. See #43131 for the rationale. | ||
# The hint above recommends this because it's more obvious usage and doesn't | ||
# require the -d flag. | ||
go get -d indirect-with-pkg indirect-without-pkg | ||
cmp go.mod go.mod.indirect | ||
|
||
|
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ cp go.mod.orig go.mod | |
go mod edit -require example.com/retract/self/[email protected] | ||
go get -d example.com/retract/self/prev | ||
stderr '^go: warning: example.com/retract/self/[email protected]: retracted by module author: self$' | ||
stderr '^go: run ''go get example.com/retract/self/prev@latest'' to switch to the latest unretracted version$' | ||
stderr '^go: to switch to the latest unretracted version, run:\n\tgo get example.com/retract/self/prev@latest$' | ||
go list -m example.com/retract/self/prev | ||
stdout '^example.com/retract/self/prev v1.9.0$' | ||
|
||
|
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 |
---|---|---|
|
@@ -66,7 +66,7 @@ stderr '^go: inconsistent vendoring in '$WORK[/\\]auto':$' | |
stderr '^\texample.com/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt' | ||
stderr '^\texample.com/unused: is replaced in go.mod, but not marked as replaced in vendor/modules.txt' | ||
stderr '^\texample.com/[email protected]: is replaced in go.mod, but not marked as replaced in vendor/modules.txt' | ||
stderr '\n\nrun .go mod vendor. to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory$' | ||
stderr '^\tTo ignore the vendor directory, use -mod=readonly or -mod=mod.\n\tTo sync the vendor directory, run:\n\t\tgo mod vendor$' | ||
|
||
# Module-specific subcommands should continue to load the full module graph. | ||
go mod graph | ||
|
@@ -135,7 +135,7 @@ stderr '^go: inconsistent vendoring in '$WORK[/\\]auto':$' | |
stderr '^\texample.com/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt' | ||
stderr '^\texample.com/unused: is replaced in go.mod, but not marked as replaced in vendor/modules.txt' | ||
stderr '^\texample.com/[email protected]: is replaced in go.mod, but not marked as replaced in vendor/modules.txt' | ||
stderr '\n\nrun .go mod vendor. to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory$' | ||
stderr '^\tTo ignore the vendor directory, use -mod=readonly or -mod=mod.\n\tTo sync the vendor directory, run:\n\t\tgo mod vendor$' | ||
|
||
# If -mod=vendor is set, limited consistency checks should apply even when | ||
# the go version is 1.13 or earlier. | ||
|
@@ -151,7 +151,7 @@ cp $WORK/modules-bad-1.13.txt vendor/modules.txt | |
! go list -mod=vendor -f {{.Dir}} -tags tools all | ||
stderr '^go: inconsistent vendoring in '$WORK[/\\]auto':$' | ||
stderr '^\texample.com/[email protected]: is explicitly required in go.mod, but vendor/modules.txt indicates example.com/[email protected]$' | ||
stderr '\n\nrun .go mod vendor. to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory$' | ||
stderr '^\tTo ignore the vendor directory, use -mod=readonly or -mod=mod.\n\tTo sync the vendor directory, run:\n\t\tgo mod vendor$' | ||
|
||
# If the go version is still 1.13, 'go mod vendor' should write a | ||
# matching vendor/modules.txt containing the corrected 1.13 data. | ||
|
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,14 +1,14 @@ | ||
# Test rejection of pkg@version in GOPATH mode. | ||
env GO111MODULE=off | ||
! go get rsc.io/[email protected] | ||
stderr 'cannot use path@version syntax in GOPATH mode' | ||
stderr '^go: can only use path@version syntax with ''go get'' and ''go install'' in module-aware mode$' | ||
! go build rsc.io/[email protected] | ||
stderr 'cannot use path@version syntax in GOPATH mode' | ||
stderr '^package rsc.io/[email protected]: can only use path@version syntax with ''go get'' and ''go install'' in module-aware mode$' | ||
|
||
env GO111MODULE=on | ||
cd x | ||
! go build rsc.io/[email protected] | ||
stderr 'can only use path@version syntax with ''go get''' | ||
stderr '^package rsc.io/[email protected]: can only use path@version syntax with ''go get'' and ''go install'' in module-aware mode$' | ||
|
||
-- x/go.mod -- | ||
module 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