...
1# If the latest unretracted version of a module is replaced, 'go list' should
2# obtain retractions from the replacement.
3
4# Populate go.sum.
5go get
6
7# The latest version, v1.9.0, is not available on the proxy.
8go list -m -retracted example.com/retract/missingmod
9stdout '^example.com/retract/missingmod v1.0.0$'
10exists $GOPATH/pkg/mod/cache/download/example.com/retract/missingmod/@v/v1.9.0.info
11! exists $GOPATH/pkg/mod/cache/download/example.com/retract/missingmod/@v/v1.9.0.mod
12
13# If we replace that version, we should see retractions.
14go mod edit -replace=example.com/retract/missingmod@v1.9.0=./missingmod-v1.9.0
15go list -m -retracted -f '{{range .Retracted}}{{.}}{{end}}' example.com/retract/missingmod
16stdout '^bad version$'
17
18# If we replace the retracted version, we should not see a retraction.
19go mod edit -replace=example.com/retract/missingmod=./missingmod-v1.9.0
20go list -m -retracted -f '{{if not .Retracted}}good version{{end}}' example.com/retract/missingmod
21stdout '^good version$'
22
23
24# If a replacement version is retracted, we should see a retraction.
25# It should appear in both the replaced module and the replacement, as other
26# fields like GoMod do.
27go list -m -retracted -f '{{range .Retracted}}{{.}}{{end}}' example.com/retract
28! stdout .
29go list -m -retracted -f '{{if .Replace}}replaced{{end}}' example.com/retract
30! stdout .
31go mod edit -replace example.com/retract@v1.0.0-good=example.com/retract@v1.0.0-bad
32go list -m -mod=mod -retracted -f '{{range .Retracted}}{{.}}{{end}}' example.com/retract
33stdout '^bad$'
34go list -m -mod=mod -retracted -f '{{with .Replace}}{{range .Retracted}}{{.}}{{end}}{{end}}' example.com/retract
35stdout '^bad$'
36
37-- go.mod --
38module m
39
40go 1.14
41
42require (
43 example.com/retract v1.0.0-good
44 example.com/retract/missingmod v1.0.0
45)
46-- use.go --
47package use
48
49import (
50 _ "example.com/retract"
51 _ "example.com/retract/missingmod"
52)
53-- missingmod-v1.0.0/go.mod --
54module example.com/retract/missingmod
55
56go 1.14
57-- missingmod-v1.9.0/go.mod --
58module example.com/retract/missingmod
59
60go 1.14
61
62// bad version
63retract v1.0.0
View as plain text