From 7ed774bdc0d941f843a2755877d6366b3b85cbf5 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 9 Feb 2016 13:14:21 -0800 Subject: [PATCH] go/gcimporter15: interpret relative srcDir relative to cwd This is a backport of the respective changes in golang.org/cl/19393. For golang/go#14215. Change-Id: I8d60dd6daa827a60597f3af925e6732914537319 Reviewed-on: https://go-review.googlesource.com/19394 Reviewed-by: Alan Donovan --- go/gcimporter15/gcimporter.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/go/gcimporter15/gcimporter.go b/go/gcimporter15/gcimporter.go index 5bc5696d..7b19b081 100644 --- a/go/gcimporter15/gcimporter.go +++ b/go/gcimporter15/gcimporter.go @@ -42,7 +42,8 @@ var pkgExts = [...]string{".a", ".o"} // FindPkg returns the filename and unique package id for an import // path based on package information provided by build.Import (using -// the build.Default build.Context). +// the build.Default build.Context). A relative srcDir is interpreted +// relative to the current working directory. // If no file was found, an empty filename is returned. // func FindPkg(path, srcDir string) (filename, id string) { @@ -55,6 +56,9 @@ func FindPkg(path, srcDir string) (filename, id string) { default: // "x" -> "$GOPATH/pkg/$GOOS_$GOARCH/x.ext", "x" // Don't require the source files to be present. + if abs, err := filepath.Abs(srcDir); err == nil { // see issue 14282 + srcDir = abs + } bp, _ := build.Import(path, srcDir, build.FindOnly|build.AllowBinary) if bp.PkgObj == "" { return