...
1cp go.mod go.mod.orig
2
3# 'go list pkg' does not report an error when a retracted version is used.
4go list -e -f '{{if .Error}}{{.Error}}{{end}}' ./use
5! stdout .
6cmp 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.
15exists $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.
20go get ./use_self_prev
21go list -m example.com/retract/self/prev
22stdout '^example.com/retract/self/prev v1.1.0$'
23exists $GOPATH/pkg/mod/cache/download/example.com/retract/self/prev/@v/v1.9.0.mod
24
25-- go.mod --
26module example.com/use
27
28go 1.15
29
30require example.com/retract v1.0.0-bad
31
32-- go.sum --
33example.com/retract v1.0.0-bad h1:liAW69rbtjY67x2CcNzat668L/w+YGgNX3lhJsWIJis=
34example.com/retract v1.0.0-bad/go.mod h1:0DvGGofJ9hr1q63cBrOY/jSY52OwhRGA0K47NE80I5Y=
35example.com/retract/self/prev v1.1.0 h1:0/8I/GTG+1eJTFeDQ/fUbgrMsVHHyKhh3Z8DSZp1fuA=
36example.com/retract/self/prev v1.1.0/go.mod h1:xl2EcklWuZZHVtHWcpzfSJQmnzAGpKZYpA/Wto7SZN4=
37-- use/use.go --
38package use
39
40import _ "example.com/retract"
41
42-- use_self_prev/use.go --
43package use_self_prev
44
45import _ "example.com/retract/self/prev"
View as plain text