Skip to content

goproxy-forward-util-succuss-or-last #32199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions src/cmd/go/internal/modfetch/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ control systems. Setting GOPROXY to "off" disallows downloading modules from
any source. Otherwise, GOPROXY is expected to be a comma-separated list of
the URLs of module proxies, in which case the go command will fetch modules
from those proxies. For each request, the go command tries each proxy in sequence,
only moving to the next if the current proxy returns a 404 or 410 HTTP response.
only moving to the next if the current proxy failed.
The string "direct" may appear in the proxy list, to cause a direct connection to
be attempted at that point in the search.

Expand Down Expand Up @@ -415,7 +415,7 @@ func (r *lazyRepo) Zip(dst io.Writer, version string) error {
// The list must be non-empty and all Repos
// must return the same result from ModulePath.
// For each method, the repos are tried in order
// until one succeeds or returns a non-ErrNotExist (non-404) error.
// until one succeeds.
type listRepo []Repo

func (l listRepo) ModulePath() string {
Expand All @@ -425,49 +425,55 @@ func (l listRepo) ModulePath() string {
func (l listRepo) Versions(prefix string) ([]string, error) {
for i, r := range l {
v, err := r.Versions(prefix)
if i == len(l)-1 || !errors.Is(err, os.ErrNotExist) {
return v, err
if err != nil && i != len(l) - 1{
continue
}
return v, err
}
panic("no repos")
}

func (l listRepo) Stat(rev string) (*RevInfo, error) {
for i, r := range l {
info, err := r.Stat(rev)
if i == len(l)-1 || !errors.Is(err, os.ErrNotExist) {
return info, err
if err != nil && i != len(l) - 1{
continue
}
return info, err
}
panic("no repos")
}

func (l listRepo) Latest() (*RevInfo, error) {
for i, r := range l {
info, err := r.Latest()
if i == len(l)-1 || !errors.Is(err, os.ErrNotExist) {
return info, err
if err != nil && i != len(l) - 1{
continue
}
return info, err
}
panic("no repos")
}

func (l listRepo) GoMod(version string) ([]byte, error) {
for i, r := range l {
data, err := r.GoMod(version)
if i == len(l)-1 || !errors.Is(err, os.ErrNotExist) {
return data, err
if err != nil && i != len(l) - 1{
continue
}
return data, err
}
panic("no repos")
}

func (l listRepo) Zip(dst io.Writer, version string) error {
for i, r := range l {
err := r.Zip(dst, version)
if i == len(l)-1 || !errors.Is(err, os.ErrNotExist) {
return err
if err != nil && i != len(l) - 1{
continue
}
return err
}
panic("no repos")
}