-
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: add support for GOPROXY list
Following discussion on golang.org/issue/26334, this CL changes the GOPROXY environment setting to be a list of proxies, tried in sequence. The first successful or non-404/410 error is taken as authoritative. Otherwise the next proxy is tried, and so on. As in earlier releases, GOPROXY=direct means "connect directly", but now it can appear in a longer list as well. This will let companies run a proxy holding only their private modules and let users set GOPROXY=thatproxy,publicproxy or GOPROXY=thatproxy,direct to fall back to an alternate mechanism for fetching public modules. Fixes #26334. Change-Id: I642f0ae655ec307d9cdcad0830c0baac8670eb9c Reviewed-on: https://go-review.googlesource.com/c/go/+/173441 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
- Loading branch information
Showing
5 changed files
with
249 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,29 @@ | ||
env GO111MODULE=on | ||
env proxy=$GOPROXY | ||
|
||
# Proxy that can't serve should fail. | ||
env GOPROXY=$proxy/404 | ||
! go get rsc.io/quote@v1.0.0 | ||
stderr '404 Not Found' | ||
|
||
# get should walk down the proxy list past 404 and 410 responses. | ||
env GOPROXY=$proxy/404,$proxy/410,$proxy | ||
go get rsc.io/quote@v1.1.0 | ||
|
||
# get should not walk past other 4xx errors. | ||
env GOPROXY=$proxy/403,$proxy | ||
! go get rsc.io/quote@v1.2.0 | ||
stderr 'reading.*/403/rsc.io/.*: 403 Forbidden' | ||
|
||
# get should not walk past non-4xx errors. | ||
env GOPROXY=$proxy/500,$proxy | ||
! go get rsc.io/quote@v1.3.0 | ||
stderr 'reading.*/500/rsc.io/.*: 500 Internal Server Error' | ||
|
||
# get should return the final 404/410 if that's all we have. | ||
env GOPROXY=$proxy/404,$proxy/410 | ||
! go get rsc.io/quote@v1.4.0 | ||
stderr 'reading.*/410/rsc.io/.*: 410 Gone' | ||
|
||
-- go.mod -- | ||
module x |