mirror of
https://github.com/golang/go
synced 2024-11-12 09:50:21 -07:00
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>
This commit is contained in:
parent
c02aa463db
commit
918edf433b
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user