1 # In GOPATH mode, module legacy support does path rewriting very similar to vendoring.
2
3 env GO111MODULE=off
4
5 go list -f '{{range .Imports}}{{.}}{{"\n"}}{{end}}' old/p1
6 stdout ^new/p1$
7
8 go list -f '{{range .Imports}}{{.}}{{"\n"}}{{end}}' new/p1
9 stdout ^new/p2$ # not new/v2/p2
10 ! stdout ^new/v2
11 stdout ^new/sub/x/v1/y$ # not new/sub/v2/x/v1/y
12 ! stdout ^new/sub/v2
13 stdout ^new/sub/inner/x # not new/sub/v2/inner/x
14
15 go build old/p1 new/p1
16
17 -- new/go.mod --
18 module "new/v2"
19 -- new/new.go --
20 package new
21
22 import _ "new/v2/p2"
23 -- new/p1/p1.go --
24 package p1
25
26 import _ "old/p2"
27 import _ "new/v2"
28 import _ "new/v2/p2"
29 import _ "new/sub/v2/x/v1/y" // v2 is module, v1 is directory in module
30 import _ "new/sub/inner/x" // new/sub/inner/go.mod overrides new/sub/go.mod
31 -- new/p2/p2.go --
32 package p2
33 -- new/sub/go.mod --
34 module new/sub/v2
35 -- new/sub/inner/go.mod --
36 module new/sub/inner
37 -- new/sub/inner/x/x.go --
38 package x
39 -- new/sub/x/v1/y/y.go --
40 package y
41 -- old/p1/p1.go --
42 package p1
43
44 import _ "old/p2"
45 import _ "new/p1"
46 import _ "new"
47 -- old/p2/p2.go --
48 package p2
49
View as plain text