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