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