]> Cypherpunks repositories - gostls13.git/commitdiff
go/importer: use correct path for path->package map
authorRobert Griesemer <gri@golang.org>
Sat, 9 Jan 2016 01:56:50 +0000 (17:56 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 11 Jan 2016 18:54:56 +0000 (18:54 +0000)
In the presence of vendored packages, the path found in a package
declaration may not be the path at which the package imported from
srcDir was found. Use the correct package path.

Change-Id: I74496c3cdf82a5dbd6a5bd189bb3cd0ca103fd52
Reviewed-on: https://go-review.googlesource.com/18460
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/internal/gcimporter/gcimporter.go

index 1402aa223e169fe88d546d0159ab8f1cfc3201ab..46006c5c2012abb3530e5513287437e7d6b83af1 100644 (file)
@@ -39,7 +39,6 @@ func FindPkg(path, srcDir string) (filename, id string) {
                return
        }
 
-       id = path
        var noext string
        switch {
        default:
@@ -50,6 +49,7 @@ func FindPkg(path, srcDir string) (filename, id string) {
                        return
                }
                noext = strings.TrimSuffix(bp.PkgObj, ".a")
+               id = bp.ImportPath
 
        case build.IsLocalImport(path):
                // "./x" -> "/this/directory/x.ext", "/this/directory/x"
@@ -61,6 +61,13 @@ func FindPkg(path, srcDir string) (filename, id string) {
                // does not support absolute imports
                // "/x" -> "/x.ext", "/x"
                noext = path
+               id = path
+       }
+
+       if false { // for debugging
+               if path != id {
+                       fmt.Printf("%s -> %s\n", path, id)
+               }
        }
 
        // try extensions