1 # Confirm our build list.
2 cp go.sum.buildlist-only go.sum
3 go list -m all
4 stdout '^example.com/ambiguous/a v1.0.0$'
5 stdout '^example.com/ambiguous/a/b v0.0.0-empty$'
6
7 # If two modules could provide a package, but only one does,
8 # 'go mod tidy' should retain sums for both zips.
9 go mod tidy
10 grep '^example.com/ambiguous/a v1.0.0 h1:' go.sum
11 grep '^example.com/ambiguous/a/b v0.0.0-empty h1:' go.sum
12
13 # 'go mod download' should also add sums.
14 cp go.sum.buildlist-only go.sum
15 go mod download example.com/ambiguous/a
16 grep '^example.com/ambiguous/a v1.0.0 h1:' go.sum
17 ! grep '^example.com/ambiguous/a/b v0.0.0-empty h1:' go.sum
18 go mod download example.com/ambiguous/a/b
19 grep '^example.com/ambiguous/a/b v0.0.0-empty h1:' go.sum
20
21 # If two modules could provide a package, and we're missing a sum for one,
22 # we should see a missing sum error, even if we have a sum for a module that
23 # provides the package.
24 cp go.sum.a-only go.sum
25 ! go list example.com/ambiguous/a/b
26 stderr '^missing go.sum entry needed to verify package example.com/ambiguous/a/b is provided by exactly one module; to add:\n\tgo mod download example.com/ambiguous/a/b$'
27 ! go list -deps .
28 stderr '^use.go:3:8: missing go.sum entry needed to verify package example.com/ambiguous/a/b \(imported by m\) is provided by exactly one module; to add:\n\tgo get m$'
29
30 cp go.sum.b-only go.sum
31 ! go list example.com/ambiguous/a/b
32 stderr '^missing go.sum entry for module providing package example.com/ambiguous/a/b; to add:\n\tgo mod download example.com/ambiguous/a$'
33 ! go list -deps .
34 stderr '^use.go:3:8: missing go.sum entry for module providing package example.com/ambiguous/a/b \(imported by m\); to add:\n\tgo get m$'
35
36 cp go.sum.buildlist-only go.sum
37 ! go list example.com/ambiguous/a/b
38 stderr '^missing go.sum entry for module providing package example.com/ambiguous/a/b; to add:\n\tgo mod download example.com/ambiguous/a example.com/ambiguous/a/b$'
39 ! go list -deps .
40 stderr '^use.go:3:8: missing go.sum entry for module providing package example.com/ambiguous/a/b \(imported by m\); to add:\n\tgo get m$'
41
42 -- go.mod --
43 module m
44
45 go 1.15
46
47 require example.com/ambiguous/a v1.0.0
48 -- go.sum.buildlist-only --
49 example.com/ambiguous/a v1.0.0/go.mod h1:TrBl/3xTPFJ2gmMIYz53h2gkNtg0dokszEMuyS1QEb0=
50 example.com/ambiguous/a/b v0.0.0-empty/go.mod h1:MajJq5jPEBnnXP+NTWIeXX7kwaPS1sbVEJdooTmsePQ=
51 -- go.sum.a-only --
52 example.com/ambiguous/a v1.0.0 h1:pGZhTXy6+titE2rNfwHwJykSjXDR4plO52PfZrBM0T8=
53 example.com/ambiguous/a v1.0.0/go.mod h1:TrBl/3xTPFJ2gmMIYz53h2gkNtg0dokszEMuyS1QEb0=
54 example.com/ambiguous/a/b v0.0.0-empty/go.mod h1:MajJq5jPEBnnXP+NTWIeXX7kwaPS1sbVEJdooTmsePQ=
55 -- go.sum.b-only --
56 example.com/ambiguous/a v1.0.0/go.mod h1:TrBl/3xTPFJ2gmMIYz53h2gkNtg0dokszEMuyS1QEb0=
57 example.com/ambiguous/a/b v0.0.0-empty h1:xS29ReXXuhjT7jc79mo91h/PevaZ2oS9PciF1DucXtg=
58 example.com/ambiguous/a/b v0.0.0-empty/go.mod h1:MajJq5jPEBnnXP+NTWIeXX7kwaPS1sbVEJdooTmsePQ=
59 -- use.go --
60 package use
61
62 import _ "example.com/ambiguous/a/b"
63
View as plain text