...
1cp 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
7go get -u example.net/a@v0.1.0 example.net/b@v0.1.0
8go list -m all
9stdout '^example.net/a v0.1.0 '
10stdout '^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
17cp go.mod.orig go.mod
18
19go get -u example.net/a@v0.1.0 example.net/b/...@v0.1.0
20go list -m all
21stdout '^example.net/a v0.1.0 '
22stdout '^example.net/b v0.1.0 '
23stdout '^example.net/c ' # BUG, but a minor and rare one
24
25
26-- go.mod --
27module example
28
29go 1.15
30
31replace (
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 --
40module example.net/a
41
42go 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 --
47package a
48import _ "example.net/b"
49
50-- b1/go.mod --
51module example.net/b
52
53go 1.15
54-- b1/b.go --
55package b
56
57-- b2/go.mod --
58module example.net/b
59
60go 1.15
61
62require example.net/c v0.1.0
63-- b2/b.go --
64package b
65
66-- c1/go.mod --
67module example.net/c
68
69go 1.15
View as plain text