Commit 918edf43 authored by Robert Griesemer's avatar Robert Griesemer

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/18460Reviewed-by: 's avatarAlan Donovan <adonovan@google.com>
parent c02aa463
...@@ -39,7 +39,6 @@ func FindPkg(path, srcDir string) (filename, id string) { ...@@ -39,7 +39,6 @@ func FindPkg(path, srcDir string) (filename, id string) {
return return
} }
id = path
var noext string var noext string
switch { switch {
default: default:
...@@ -50,6 +49,7 @@ func FindPkg(path, srcDir string) (filename, id string) { ...@@ -50,6 +49,7 @@ func FindPkg(path, srcDir string) (filename, id string) {
return return
} }
noext = strings.TrimSuffix(bp.PkgObj, ".a") noext = strings.TrimSuffix(bp.PkgObj, ".a")
id = bp.ImportPath
case build.IsLocalImport(path): case build.IsLocalImport(path):
// "./x" -> "/this/directory/x.ext", "/this/directory/x" // "./x" -> "/this/directory/x.ext", "/this/directory/x"
...@@ -61,6 +61,13 @@ func FindPkg(path, srcDir string) (filename, id string) { ...@@ -61,6 +61,13 @@ func FindPkg(path, srcDir string) (filename, id string) {
// does not support absolute imports // does not support absolute imports
// "/x" -> "/x.ext", "/x" // "/x" -> "/x.ext", "/x"
noext = path noext = path
id = path
}
if false { // for debugging
if path != id {
fmt.Printf("%s -> %s\n", path, id)
}
} }
// try extensions // try extensions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment