...
1env GO111MODULE=off
2
3[!cgo] skip
4
5# go list should report import "C"
6cd x
7go list -f '{{.Imports}}'
8! stdout runtime/cgo
9! stdout unsafe
10! stdout syscall
11stdout C
12stdout unicode
13stdout unicode/utf16
14
15# go list -compiled should report imports in compiled files as well,
16# adding "runtime/cgo", "unsafe", and "syscall" but not dropping "C".
17go list -compiled -f '{{.Imports}}'
18stdout runtime/cgo
19stdout unsafe
20stdout syscall
21stdout C
22stdout unicode
23stdout unicode/utf16
24
25-- x/x.go --
26package x
27import "C"
28import "unicode" // does not use unsafe, syscall, runtime/cgo, unicode/utf16
29-- x/x1.go --
30package x
31import "unicode/utf16" // does not use unsafe, syscall, runtime/cgo, unicode
View as plain text