aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2016-01-08 17:56:50 -0800
committerRobert Griesemer <gri@golang.org>2016-01-11 18:54:56 +0000
commit918edf433b363d26d176d4cd6bc4c3928cc2520e (patch)
tree811d0887c48bb7208257f991d2c738daeef4882b
parentc02aa463db0c5867a4ae1adfc2f98c436cb751b0 (diff)
downloadgo-918edf433b363d26d176d4cd6bc4c3928cc2520e.tar.gz
go-918edf433b363d26d176d4cd6bc4c3928cc2520e.zip
go/importer: use correct path for path->package map
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>
-rw-r--r--src/go/internal/gcimporter/gcimporter.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/go/internal/gcimporter/gcimporter.go b/src/go/internal/gcimporter/gcimporter.go
index 1402aa223e..46006c5c20 100644
--- a/src/go/internal/gcimporter/gcimporter.go
+++ b/src/go/internal/gcimporter/gcimporter.go
@@ -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