diff options
author | Russ Cox <rsc@golang.org> | 2018-08-09 23:44:43 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2018-08-10 18:52:40 +0000 |
commit | 64205cd4b6d48432fdcbe2127d45e4f786468ff3 (patch) | |
tree | 4083b7065fff9b46ab07ec857e8f5a646eef44dc /src/cmd/go/internal/list/list.go | |
parent | e652b7e63f1ea71d487953bf948f371189755446 (diff) | |
download | go-64205cd4b6d48432fdcbe2127d45e4f786468ff3.tar.gz go-64205cd4b6d48432fdcbe2127d45e4f786468ff3.zip |
cmd/go: report implicit cgo inputs in go list -compiled
Tools using go list -compiled expect to see an Imports list
that includes all the imports in CompiledGoFiles.
Make sure the list includes the cgo-generated imports.
Fixes #26136.
Change-Id: I6cfe14063f8edfe65a7af37522c7551272115b82
Reviewed-on: https://go-review.googlesource.com/128935
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/list/list.go')
-rw-r--r-- | src/cmd/go/internal/list/list.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cmd/go/internal/list/list.go b/src/cmd/go/internal/list/list.go index dd9ec5a9e5..e75270fa55 100644 --- a/src/cmd/go/internal/list/list.go +++ b/src/cmd/go/internal/list/list.go @@ -20,6 +20,7 @@ import ( "cmd/go/internal/cfg" "cmd/go/internal/load" "cmd/go/internal/modload" + "cmd/go/internal/str" "cmd/go/internal/work" ) @@ -146,7 +147,8 @@ instead of using the template format. The -compiled flag causes list to set CompiledGoFiles to the Go source files presented to the compiler. Typically this means that it repeats the files listed in GoFiles and then also adds the Go code generated -by processing CgoFiles and SwigFiles. +by processing CgoFiles and SwigFiles. The Imports list contains the +union of all imports from both GoFiles and CompiledGoFiles. The -deps flag causes list to iterate over not just the named packages but also all their dependencies. It visits them in a depth-first post-order @@ -517,6 +519,10 @@ func runList(cmd *base.Command, args []string) { p.TestImports = p.Resolve(p.TestImports) p.XTestImports = p.Resolve(p.XTestImports) p.DepOnly = !cmdline[p] + + if *listCompiled { + p.Imports = str.StringList(p.Imports, p.Internal.CompiledImports) + } } if *listTest { |