...
1# Check that 'go get -u' will upgrade a dependency (direct or indirect)
2# when the main module and the dependency are both lazy.
3# Verifies #47768.
4
5# Check that go.mod is tidy, and an upgrade is available.
6cp go.mod go.mod.orig
7go mod tidy
8cmp go.mod go.mod.orig
9
10go list -m -u example.com/lazyupgrade
11stdout '^example.com/lazyupgrade v0.1.0 \[v0.1.1\] => ./lazyupgrade@v0.1.0$'
12
13# 'go get -u' on a package that directly imports the dependency should upgrade.
14go get -u ./usedirect
15go list -m example.com/lazyupgrade
16stdout '^example.com/lazyupgrade v0.1.1 => ./lazyupgrade@v0.1.1$'
17cp go.mod.orig go.mod
18
19# 'go get -u' on a package that indirectly imports the dependency should upgrade.
20go get -u ./useindirect
21go list -m example.com/lazyupgrade
22stdout '^example.com/lazyupgrade v0.1.1 => ./lazyupgrade@v0.1.1$'
23
24-- go.mod --
25module use
26
27go 1.17
28
29require (
30 direct v0.0.0
31 example.com/lazyupgrade v0.1.0
32)
33
34replace (
35 direct => ./direct
36 example.com/lazyupgrade v0.1.0 => ./lazyupgrade@v0.1.0
37 example.com/lazyupgrade v0.1.1 => ./lazyupgrade@v0.1.1
38)
39-- usedirect/usedirect.go --
40package use
41
42import _ "example.com/lazyupgrade"
43-- useindirect/useindirect.go --
44package use
45
46import _ "direct"
47-- direct/go.mod --
48module direct
49
50go 1.17
51
52require example.com/lazyupgrade v0.1.0
53-- direct/direct.go --
54package direct
55
56import _ "example.com/lazyupgrade"
57-- lazyupgrade@v0.1.0/go.mod --
58module example.com/lazyupgrade
59
60go 1.17
61-- lazyupgrade@v0.1.0/lazyupgrade.go --
62package lazyupgrade
63-- lazyupgrade@v0.1.1/go.mod --
64module example.com/lazyupgrade
65
66go 1.17
67-- lazyupgrade@v0.1.1/lazyupgrade.go --
68package lazyupgrade
View as plain text