1 cp go.mod go.mod.orig
2
3 # 'go list pkg' does not report an error when a retracted version is used.
4 go list -e -f '{{if .Error}}{{.Error}}{{end}}' ./use
5 ! stdout .
6 cmp go.mod go.mod.orig
7
8 # Nor does 'go build'.
9 [!short] go build ./use
10 [!short] ! stderr .
11 [!short] cmp go.mod go.mod.orig
12
13 # Neither 'go list' nor 'go build' should download go.mod from the version
14 # that would list retractions.
15 exists $GOPATH/pkg/mod/cache/download/example.com/retract/@v/v1.0.0-bad.mod
16 ! exists $GOPATH/pkg/mod/cache/download/example.com/retract/@v/v1.1.0.mod
17
18 # Importing a package from a module with a retracted latest version will
19 # select the latest non-retracted version.
20 go get ./use_self_prev
21 go list -m example.com/retract/self/prev
22 stdout '^example.com/retract/self/prev v1.1.0$'
23 exists $GOPATH/pkg/mod/cache/download/example.com/retract/self/prev/@v/v1.9.0.mod
24
25 -- go.mod --
26 module example.com/use
27
28 go 1.15
29
30 require example.com/retract v1.0.0-bad
31
32 -- go.sum --
33 example.com/retract v1.0.0-bad h1:liAW69rbtjY67x2CcNzat668L/w+YGgNX3lhJsWIJis=
34 example.com/retract v1.0.0-bad/go.mod h1:0DvGGofJ9hr1q63cBrOY/jSY52OwhRGA0K47NE80I5Y=
35 example.com/retract/self/prev v1.1.0 h1:0/8I/GTG+1eJTFeDQ/fUbgrMsVHHyKhh3Z8DSZp1fuA=
36 example.com/retract/self/prev v1.1.0/go.mod h1:xl2EcklWuZZHVtHWcpzfSJQmnzAGpKZYpA/Wto7SZN4=
37 -- use/use.go --
38 package use
39
40 import _ "example.com/retract"
41
42 -- use_self_prev/use.go --
43 package use_self_prev
44
45 import _ "example.com/retract/self/prev"
46
View as plain text