1 env GO111MODULE=on
2 env sumdb=$GOSUMDB
3 env proxy=$GOPROXY
4 env GOPROXY GONOPROXY GOSUMDB GONOSUMDB
5
6 # basic fetch (through proxy) works
7 cp go.mod.orig go.mod
8 go get rsc.io/fortune@v1.0.0 # note: must use test proxy, does not exist in real world
9 rm $GOPATH/pkg/mod/cache/download/sumdb # rm sumdb cache but NOT package download cache
10 rm go.sum
11
12 # can fetch by explicit URL
13 cp go.mod.orig go.mod
14 env GOSUMDB=$sumdb' '$proxy/sumdb-direct
15 go get rsc.io/fortune@v1.0.0
16 rm $GOPATH/pkg/mod/cache/download/sumdb
17 rm go.sum
18
19 # direct access fails (because localhost.localdev does not exist)
20 # web.get is providing the error message - there's no actual network access.
21 cp go.mod.orig go.mod
22 env GOSUMDB=$sumdb
23 env GOPROXY=direct
24 ! go get rsc.io/fortune@v1.0.0
25 stderr 'verifying module: rsc.io/fortune@v1.0.0: .*: no such host localhost.localdev'
26 rm $GOPATH/pkg/mod/cache/download/sumdb
27 rm go.sum
28
29 # proxy 404 falls back to direct access (which fails)
30 cp go.mod.orig go.mod
31 env GOSUMDB=$sumdb
32 env GOPROXY=$proxy/sumdb-404
33 ! go get rsc.io/fortune@v1.0.0
34 stderr 'verifying.*localhost.localdev'
35 rm $GOPATH/pkg/mod/cache/download/sumdb
36 rm go.sum
37
38 # proxy non-200/404/410 stops direct access
39 cp go.mod.orig go.mod
40 env GOSUMDB=$sumdb
41 env GOPROXY=$proxy/sumdb-503
42 ! go get rsc.io/fortune@v1.0.0
43 stderr '503 Service Unavailable'
44 rm $GOPATH/pkg/mod/cache/download/sumdb
45 rm go.sum
46
47 # the error from the last attempted proxy should be returned.
48 cp go.mod.orig go.mod
49 env GOSUMDB=$sumdb
50 env GOPROXY=$proxy/sumdb-404,$proxy/sumdb-503
51 ! go get rsc.io/fortune@v1.0.0
52 stderr '503 Service Unavailable'
53 rm $GOPATH/pkg/mod/cache/download/sumdb
54 rm go.sum
55
56 # if proxies are separated with '|', fallback is allowed on any error.
57 cp go.mod.orig go.mod
58 env GOSUMDB=$sumdb
59 env GOPROXY=$proxy/sumdb-503|https://0.0.0.0|$proxy
60 go get rsc.io/fortune@v1.0.0
61 rm $GOPATH/pkg/mod/cache/download/sumdb
62 rm go.sum
63
64 -- go.mod.orig --
65 module m
66
View as plain text