Repository: go
Issue: cmd/go: package resolution fails after selecting incorrect module when using multiple proxies
Labels: NeedsFix,modules

<!--
Please answer these questions before submitting your issue. Thanks!
For questions please use one of our forums: https://github.com/golang/go/wiki/Questions
-->

### What version of Go are you using (`go version`)?

<pre>
$ go version
prime@bee /t/b/bugmod> go version
go version go1.14.6 linux/amd64
</pre>

### Does this issue reproduce with the latest release?
Yes

### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/prime/.cache/go-build"
GOENV="/home/prime/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/prime/Code/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/bug/bugmod/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build264271803=/tmp/go-build -gno-record-gcc-switches"
</pre></details>

### What did you do?

GOPROXY environment variable may contain list of proxy URLs, that should be tried in turn. I found edge case, where multiple proxies are handled incorrectly.

```sh
prime@bee /> mkdir /tmp/bug
prime@bee /> cd /tmp/bug
prime@bee /t/bug> mkdir bugmod emptygopath proxy0 proxy1 tmpmod

prime@bee /t/bug> # Initialize first proxy.
prime@bee /t/bug> cd tmpmod
prime@bee /t/b/tmpmod> go mod init tmpmod
go: creating new go.mod: module tmpmod
prime@bee /t/b/tmpmod> env GOPATH=/tmp/bug/proxy0 go get rsc.io/quote
go: downloading rsc.io/quote v1.5.2
go: rsc.io/quote upgrade => v1.5.2
go: downloading rsc.io/sampler v1.3.0
go: downloading golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c
prime@bee /t/b/tmpmod> env GOPATH=/tmp/bug/proxy0 go mod download

prime@bee /t/b/tmpmod> # Initialize second proxy.
prime@bee /t/b/tmpmod> env GOPATH=/tmp/bug/proxy1 go get rsc.io/quote/v3
go: downloading rsc.io/quote v1.5.2
go: downloading rsc.io/quote/v3 v3.1.0
go: rsc.io/quote/v3 upgrade => v3.1.0
go: downloading rsc.io/sampler v1.3.0
go: downloading golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c
prime@bee /t/b/tmpmod> env GOPATH=/tmp/bug/proxy1 go mod download

prime@bee /t/b/tmpmod> # Trigger bug.
prime@bee /t/b/tmpmod> cd ../bugmod
prime@bee /t/b/bugmod> go mod init bugmod
prime@bee /t/b/bugmod> env GOPATH=/tmp/bug/emptygopath GOPROXY=file:///tmp/bug/proxy0/pkg/mod/cache/download,file:///tmp/bug/proxy1/pkg/mod/cache/download go get rsc.io/quote/v3
go: downloading rsc.io/quote v1.5.2
go get rsc.io/quote/v3: module rsc.io/quote@upgrade found (v1.5.2), but does not contain package rsc.io/quote/v3
```

### What did you expect to see?
go get downloading rsc.io/quote/v3 module from the second proxy.

### What did you see instead?
go get command is downloading rsc.io/quote module from the first proxy and failing with error.