...
1env GO111MODULE=on
2
3# initial standalone module should use no downloaded modules
4go list -deps -f {{.Dir}}
5! stdout 'pkg[\\/]mod'
6
7# v2 import should use a downloaded module
8# both without an explicit go.mod entry ...
9cp tmp/use_v2.go x.go
10go get .
11go list -deps -f {{.Dir}}
12stdout 'pkg[\\/]mod[\\/]rsc.io[\\/]quote[\\/]v2@v2.0.1$'
13
14# ... and with one ...
15cp tmp/use_v2.mod go.mod
16go list -deps -f {{.Dir}}
17stdout 'pkg[\\/]mod[\\/]rsc.io[\\/]quote[\\/]v2@v2.0.1$'
18
19# ... and even if there is a v2 module in a subdirectory.
20mkdir v2
21cp x.go v2/x.go
22cp tmp/v2.mod v2/go.mod
23go list -deps -f {{.Dir}}
24stdout 'pkg[\\/]mod[\\/]rsc.io[\\/]quote[\\/]v2@v2.0.1$'
25
26-- go.mod --
27module rsc.io/quote
28
29-- x.go --
30package quote
31
32-- tmp/use_v2.go --
33package quote
34import _ "rsc.io/quote/v2"
35
36-- tmp/use_v2.mod --
37module rsc.io/quote
38require rsc.io/quote/v2 v2.0.1
39
40-- tmp/v2.mod --
41package rsc.io/quote/v2
View as plain text