1 go mod tidy
2 cp go.mod go.mod.orig
3
4 # If there is no sensible *package* meaning for 'm/p', it should refer
5 # to *module* m/p.
6
7 go get m/p # @latest
8 go list -m all
9 stdout '^m/p v0.3.0 '
10 ! stdout '^m '
11
12 cp go.mod.orig go.mod
13
14 go get m/p@v0.1.0
15 go list -m all
16 stdout '^m/p v0.1.0 '
17 ! stdout '^m '
18
19 # When feasible, the argument 'm/p' in 'go get m/p' refers to *package* m/p,
20 # which is in module m.
21 #
22 # (It only refers to *module* m/p if there is no such package at the
23 # requested version.)
24
25 go get m/p@v0.2.0
26 go list -m all
27 stdout '^m v0.2.0 '
28 stdout '^m/p v0.1.0 ' # unchanged from the previous case
29
30 # Repeating the above with module m/p already in the module graph does not
31 # change its meaning.
32
33 go get m/p@v0.2.0
34 go list -m all
35 stdout '^m v0.2.0 '
36 stdout '^m/p v0.1.0 '
37
38 -- go.mod --
39 module example.com
40
41 go 1.16
42
43 replace (
44 m v0.1.0 => ./m01
45 m v0.2.0 => ./m02
46 m v0.3.0 => ./m03
47 m/p v0.1.0 => ./mp01
48 m/p v0.2.0 => ./mp02
49 m/p v0.3.0 => ./mp03
50 )
51 -- m01/go.mod --
52 module m
53
54 go 1.16
55 -- m01/README.txt --
56 Module m at v0.1.0 does not yet contain package p.
57
58 -- m02/go.mod --
59 module m
60
61 go 1.16
62
63 require m/p v0.1.0
64 -- m02/p/p.go --
65 // Package p is present in module m, but not module m/p.
66 package p
67
68 -- m03/go.mod --
69 module m
70
71 go 1.16
72
73 require m/p v0.1.0
74 -- m03/README.txt --
75 Module m at v0.3.0 no longer contains package p.
76
77 -- mv2/go.mod --
78 module m/v2
79
80 go 1.16
81 -- mv2/README.txt --
82 This module is m/v2. It doesn't actually need to exist,
83 but it explains how module m could plausibly exist
84 and still contain package p at 'latest' even when module
85 m/p also exists.
86
87 -- mp01/go.mod --
88 module m/p
89
90 go 1.16
91 -- mp01/README.txt --
92 This module is m/p.
93 Package m/p does not exist in this module.
94 -- mp02/go.mod --
95 module m/p
96
97 go 1.16
98 -- mp02/README.txt --
99 This module is m/p.
100 Package m/p does not exist in this module.
101 -- mp03/go.mod --
102 module m/p
103
104 go 1.16
105 -- mp03/README.txt --
106 This module is m/p.
107 Package m/p does not exist in this module.
108
View as plain text