1 # 'go get pkg' should not upgrade to a retracted version.
2 cp go.mod.orig go.mod
3 go mod edit -require example.com/retract/self/prev@v1.1.0
4 go get example.com/retract/self/prev
5 go list -m example.com/retract/self/prev
6 stdout '^example.com/retract/self/prev v1.1.0$'
7
8 # 'go get pkg' should not downgrade from a retracted version when no higher
9 # version is available.
10 cp go.mod.orig go.mod
11 go mod edit -require example.com/retract/self/prev@v1.9.0
12 go get example.com/retract/self/prev
13 stderr '^go: warning: example.com/retract/self/prev@v1.9.0: retracted by module author: self$'
14 stderr '^go: to switch to the latest unretracted version, run:\n\tgo get example.com/retract/self/prev@latest\n$'
15 go list -m example.com/retract/self/prev
16 stdout '^example.com/retract/self/prev v1.9.0$'
17
18 # 'go get pkg@latest' should downgrade from a retracted version.
19 cp go.mod.orig go.mod
20 go mod edit -require example.com/retract/self/prev@v1.9.0
21 go get example.com/retract/self/prev@latest
22 go list -m example.com/retract/self/prev
23 stdout '^example.com/retract/self/prev v1.1.0$'
24
25 # 'go get pkg@version' should update to a specific version, even if that
26 # version is retracted.
27 cp go.mod.orig go.mod
28 go get example.com/retract@v1.0.0-bad
29 stderr '^go: warning: example.com/retract@v1.0.0-bad: retracted by module author: bad$'
30 go list -m example.com/retract
31 stdout '^example.com/retract v1.0.0-bad$'
32
33 # 'go get -u' should not downgrade from a retracted version when no higher
34 # version is available.
35 cp go.mod.orig go.mod
36 go mod edit -require example.com/retract/self/prev@v1.9.0
37 go get -u ./use
38 stderr '^go: warning: example.com/retract/self/prev@v1.9.0: retracted by module author: self$'
39 go list -m example.com/retract/self/prev
40 stdout '^example.com/retract/self/prev v1.9.0$'
41
42 # 'go get' should warn if a module needed to build named packages is retracted.
43 # 'go get' should not warn about unrelated modules.
44 go get ./empty
45 ! stderr retracted
46 go get ./use
47 stderr '^go: warning: example.com/retract/self/prev@v1.9.0: retracted by module author: self$'
48
49 -- go.mod.orig --
50 module example.com/use
51
52 go 1.15
53
54 -- use/use.go --
55 package use
56
57 import _ "example.com/retract/self/prev"
58 -- empty/empty.go --
59 package empty
60
View as plain text