| 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. |
| 5 |
go get |
| 6 |
|
| 7 |
# The latest version, v1.9.0, is not available on the proxy. |
| 8 |
go list -m -retracted example.com/retract/missingmod |
| 9 |
stdout '^example.com/retract/missingmod v1.0.0$' |
| 10 |
exists $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. |
| 14 |
go mod edit -replace=example.com/retract/[email protected]=./missingmod-v1.9.0 |
| 15 |
go list -m -retracted -f '{{range .Retracted}}{{.}}{{end}}' example.com/retract/missingmod |
| 16 |
stdout '^bad version$' |
| 17 |
|
| 18 |
# If we replace the retracted version, we should not see a retraction. |
| 19 |
go mod edit -replace=example.com/retract/missingmod=./missingmod-v1.9.0 |
| 20 |
go list -m -retracted -f '{{if not .Retracted}}good version{{end}}' example.com/retract/missingmod |
| 21 |
stdout '^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. |
| 27 |
go list -m -retracted -f '{{range .Retracted}}{{.}}{{end}}' example.com/retract |
| 28 |
! stdout . |
| 29 |
go list -m -retracted -f '{{if .Replace}}replaced{{end}}' example.com/retract |
| 30 |
! stdout . |
| 31 |
go mod edit -replace example.com/[email protected]=example.com/[email protected] |
| 32 |
go list -m -mod=mod -retracted -f '{{range .Retracted}}{{.}}{{end}}' example.com/retract |
| 33 |
stdout '^bad$' |
| 34 |
go list -m -mod=mod -retracted -f '{{with .Replace}}{{range .Retracted}}{{.}}{{end}}{{end}}' example.com/retract |
| 35 |
stdout '^bad$' |
| 36 |
|
| 37 |
-- go.mod -- |
| 38 |
module m |
| 39 |
|
| 40 |
go 1.14 |
| 41 |
|
| 42 |
require ( |
| 43 |
example.com/retract v1.0.0-good |
| 44 |
example.com/retract/missingmod v1.0.0 |
| 45 |
) |
| 46 |
-- use.go -- |
| 47 |
package use |
| 48 |
|
| 49 |
import ( |
| 50 |
_ "example.com/retract" |
| 51 |
_ "example.com/retract/missingmod" |
| 52 |
) |
| 53 |
-- missingmod-v1.0.0/go.mod -- |
| 54 |
module example.com/retract/missingmod |
| 55 |
|
| 56 |
go 1.14 |
| 57 |
-- missingmod-v1.9.0/go.mod -- |
| 58 |
module example.com/retract/missingmod |
| 59 |
|
| 60 |
go 1.14 |
| 61 |
|
| 62 |
// bad version |
| 63 |
retract v1.0.0 |