-
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/internal/modfetch: return structured errors from proxy operations
CL 181881 added structured error types for direct fetches. Use those same structured errors to format proxy errors consistently. Also ensure that an empty @v/list is treated as equivalent to the module not existing at all. Updates #27173 Updates #32715 Change-Id: I203fd8259bc4f28b3389745f1a1fde936b0fa24d Reviewed-on: https://go-review.googlesource.com/c/go/+/183619 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
- Loading branch information
Bryan C. Mills
committed
Jun 25, 2019
1 parent
df901bc
commit e28f0d9
Showing
6 changed files
with
113 additions
and
21 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
env GO111MODULE=on | ||
env GOSUMDB=off | ||
|
||
go mod download example.com/[email protected] | ||
|
||
# If the proxy serves a bogus result for the @latest version, | ||
# reading that version should cause 'go get' to fail. | ||
env GOPROXY=file:///$WORK/badproxy | ||
cp go.mod.orig go.mod | ||
! go get -d example.com/join/subpkg | ||
stderr 'go get example.com/join/subpkg: example.com/join/[email protected]: .*' | ||
|
||
# If @v/list is empty, the 'go' command should still try to resolve | ||
# other module paths. | ||
env GOPROXY=file:///$WORK/emptysub | ||
cp go.mod.orig go.mod | ||
go get -d example.com/join/subpkg | ||
go list -m example.com/join/... | ||
! stdout 'example.com/join/subpkg' | ||
stdout 'example.com/join v1.1.0' | ||
|
||
# If @v/list includes a version that the proxy does not actually serve, | ||
# that version is treated as nonexistent. | ||
env GOPROXY=file:///$WORK/notfound | ||
cp go.mod.orig go.mod | ||
go get -d example.com/join/subpkg | ||
go list -m example.com/join/... | ||
! stdout 'example.com/join/subpkg' | ||
stdout 'example.com/join v1.1.0' | ||
|
||
-- go.mod.orig -- | ||
module example.com/othermodule | ||
go 1.13 | ||
-- $WORK/badproxy/example.com/join/subpkg/@v/list -- | ||
v0.0.0-20190624000000-123456abcdef | ||
-- $WORK/badproxy/example.com/join/subpkg/@v/v0.0.0-20190624000000-123456abcdef.info -- | ||
This file is not valid JSON. | ||
-- $WORK/badproxy/example.com/join/@v/list -- | ||
v1.1.0 | ||
-- $WORK/badproxy/example.com/join/@v/v1.1.0.info -- | ||
{"Version": "v1.1.0"} | ||
-- $WORK/emptysub/example.com/join/subpkg/@v/list -- | ||
-- $WORK/emptysub/example.com/join/@v/list -- | ||
v1.1.0 | ||
-- $WORK/emptysub/example.com/join/@v/v1.1.0.info -- | ||
{"Version": "v1.1.0"} | ||
-- $WORK/notfound/example.com/join/subpkg/@v/list -- | ||
v1.0.0-does-not-exist | ||
-- $WORK/notfound/example.com/join/@v/list -- | ||
v1.1.0 | ||
-- $WORK/notfound/example.com/join/@v/v1.1.0.info -- | ||
{"Version": "v1.1.0"} |