1 cp go.mod go.mod.orig
2
3 # The -u flag should not (even temporarily) upgrade modules whose versions are
4 # determined by explicit queries to any version other than the explicit one.
5 # Otherwise, 'go get -u' could introduce spurious dependencies.
6
7 go get -u example.net/a@v0.1.0 example.net/b@v0.1.0
8 go list -m all
9 stdout '^example.net/a v0.1.0 '
10 stdout '^example.net/b v0.1.0 '
11 ! stdout '^example.net/c '
12
13
14 # TODO(bcmills): This property does not yet hold for modules added for
15 # missing packages when the newly-added module matches a wildcard.
16
17 cp go.mod.orig go.mod
18
19 go get -u example.net/a@v0.1.0 example.net/b/...@v0.1.0
20 go list -m all
21 stdout '^example.net/a v0.1.0 '
22 stdout '^example.net/b v0.1.0 '
23 stdout '^example.net/c ' # BUG, but a minor and rare one
24
25
26 -- go.mod --
27 module example
28
29 go 1.15
30
31 replace (
32 example.net/a v0.1.0 => ./a1
33 example.net/b v0.1.0 => ./b1
34 example.net/b v0.2.0 => ./b2
35 example.net/c v0.1.0 => ./c1
36 example.net/c v0.2.0 => ./c1
37 )
38
39 -- a1/go.mod --
40 module example.net/a
41
42 go 1.15
43
44 // example.net/a needs a dependency on example.net/b, but lacks a requirement
45 // on it (perhaps due to a missed file in a VCS commit).
46 -- a1/a.go --
47 package a
48 import _ "example.net/b"
49
50 -- b1/go.mod --
51 module example.net/b
52
53 go 1.15
54 -- b1/b.go --
55 package b
56
57 -- b2/go.mod --
58 module example.net/b
59
60 go 1.15
61
62 require example.net/c v0.1.0
63 -- b2/b.go --
64 package b
65
66 -- c1/go.mod --
67 module example.net/c
68
69 go 1.15
70
View as plain text