...
1# retract must not be used without a module directive.
2! go list -m all
3stderr 'go.mod:3: no module directive found, so retract cannot be used$'
4
5# Commands that update go.mod should fix non-canonical versions in
6# retract directives.
7# Verifies #44494.
8go mod edit -module=rsc.io/quote/v2
9! go list -m all
10stderr '^go: updates to go.mod needed; to update it:\n\tgo mod tidy$'
11go mod tidy
12go list -m all
13cmp go.mod go.mod.want
14
15# If a retracted version doesn't match the module's major version suffx,
16# an error should be reported.
17! go mod edit -retract=v3.0.1
18stderr '^go: -retract=v3.0.1: version "v3.0.1" invalid: should be v2, not v3$'
19cp go.mod.mismatch-v2 go.mod
20! go list -m all
21stderr 'go.mod:3: retract rsc.io/quote/v2: version "v3.0.1" invalid: should be v2, not v3$'
22
23cp go.mod.mismatch-v1 go.mod
24! go list -m all
25stderr 'go.mod:3: retract rsc.io/quote: version "v3.0.1" invalid: should be v0 or v1, not v3$'
26
27-- go.mod --
28go 1.16
29
30retract latest
31-- go.mod.want --
32go 1.16
33
34retract v2.0.1
35
36module rsc.io/quote/v2
37-- go.mod.mismatch-v2 --
38go 1.16
39
40retract v3.0.1
41
42module rsc.io/quote/v2
43-- go.mod.mismatch-v1 --
44go 1.16
45
46retract v3.0.1
47
48module rsc.io/quote
View as plain text