1 # Imports
2 env GO111MODULE=off
3
4 # Pass -e to permit errors (e.g. bad.go, invalid.go)
5 go list -f '{{.ImportPath}} {{.Imports}}' -e 'vend/...' 'vend/vendor/...' 'vend/x/vendor/...'
6 cmp stdout want_vendor_imports.txt
7
8 -- want_vendor_imports.txt --
9 vend [vend/vendor/p r]
10 vend/dir1 []
11 vend/hello [fmt vend/vendor/strings]
12 vend/subdir [vend/vendor/p r]
13 vend/x [vend/x/vendor/p vend/vendor/q vend/x/vendor/r vend/dir1 vend/vendor/vend/dir1/dir2]
14 vend/x/invalid [vend/x/invalid/vendor/foo]
15 vend/vendor/p []
16 vend/vendor/q []
17 vend/vendor/strings []
18 vend/vendor/vend/dir1/dir2 []
19 vend/x/vendor/p []
20 vend/x/vendor/p/p [notfound]
21 vend/x/vendor/r []
22 -- vend/bad.go --
23 package vend
24
25 import _ "r"
26 -- vend/dir1/dir1.go --
27 package dir1
28 -- vend/good.go --
29 package vend
30
31 import _ "p"
32 -- vend/hello/hello.go --
33 package main
34
35 import (
36 "fmt"
37 "strings" // really ../vendor/strings
38 )
39
40 func main() {
41 fmt.Printf("%s\n", strings.Msg)
42 }
43 -- vend/hello/hello_test.go --
44 package main
45
46 import (
47 "strings" // really ../vendor/strings
48 "testing"
49 )
50
51 func TestMsgInternal(t *testing.T) {
52 if strings.Msg != "hello, world" {
53 t.Fatalf("unexpected msg: %v", strings.Msg)
54 }
55 }
56 -- vend/hello/hellox_test.go --
57 package main_test
58
59 import (
60 "strings" // really ../vendor/strings
61 "testing"
62 )
63
64 func TestMsgExternal(t *testing.T) {
65 if strings.Msg != "hello, world" {
66 t.Fatalf("unexpected msg: %v", strings.Msg)
67 }
68 }
69 -- vend/subdir/bad.go --
70 package subdir
71
72 import _ "r"
73 -- vend/subdir/good.go --
74 package subdir
75
76 import _ "p"
77 -- vend/vendor/p/p.go --
78 package p
79 -- vend/vendor/q/q.go --
80 package q
81 -- vend/vendor/strings/msg.go --
82 package strings
83
84 var Msg = "hello, world"
85 -- vend/vendor/vend/dir1/dir2/dir2.go --
86 package dir2
87 -- vend/x/invalid/invalid.go --
88 package invalid
89
90 import "vend/x/invalid/vendor/foo"
91 -- vend/x/vendor/p/p/p.go --
92 package p
93
94 import _ "notfound"
95 -- vend/x/vendor/p/p.go --
96 package p
97 -- vend/x/vendor/r/r.go --
98 package r
99 -- vend/x/x.go --
100 package x
101
102 import _ "p"
103 import _ "q"
104 import _ "r"
105 import _ "vend/dir1" // not vendored
106 import _ "vend/dir1/dir2" // vendored
107
View as plain text