aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/list/list.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2021-06-08 15:53:08 -0400
committerBryan C. Mills <bcmills@google.com>2021-06-10 19:59:02 +0000
commit8d11b1d1172817359d08231deaf29f72d315b762 (patch)
tree2160a903ff721d086a71f5910574ddf4bb895a30 /src/cmd/go/internal/list/list.go
parentdc00dc6c6bf3b5554e37f60799aec092276ff807 (diff)
downloadgo-8d11b1d1172817359d08231deaf29f72d315b762.tar.gz
go-8d11b1d1172817359d08231deaf29f72d315b762.zip
cmd/go: report the imports of CompiledGoFiles in ImportMap
Ideally we should encode the load.PackageInternal data in a way that doesn't rely on 1:1 correlations of slices, but this is a minimal fix to unblock Go 1.17. Fixes #46462 Change-Id: I6e029c69f757aadc54d4be02c01d6b294c217542 Reviewed-on: https://go-review.googlesource.com/c/go/+/326610 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/cmd/go/internal/list/list.go')
-rw-r--r--src/cmd/go/internal/list/list.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/cmd/go/internal/list/list.go b/src/cmd/go/internal/list/list.go
index 53aaf311ec..7cb9ec6d94 100644
--- a/src/cmd/go/internal/list/list.go
+++ b/src/cmd/go/internal/list/list.go
@@ -724,8 +724,18 @@ func runList(ctx context.Context, cmd *base.Command, args []string) {
// Record non-identity import mappings in p.ImportMap.
for _, p := range pkgs {
- for i, srcPath := range p.Internal.RawImports {
- path := p.Imports[i]
+ nRaw := len(p.Internal.RawImports)
+ for i, path := range p.Imports {
+ var srcPath string
+ if i < nRaw {
+ srcPath = p.Internal.RawImports[i]
+ } else {
+ // This path is not within the raw imports, so it must be an import
+ // found only within CompiledGoFiles. Those paths are found in
+ // CompiledImports.
+ srcPath = p.Internal.CompiledImports[i-nRaw]
+ }
+
if path != srcPath {
if p.ImportMap == nil {
p.ImportMap = make(map[string]string)