]> Cypherpunks repositories - gostls13.git/commitdiff
go/build: fix import check
authorRuss Cox <rsc@golang.org>
Tue, 27 Mar 2012 15:16:10 +0000 (11:16 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 27 Mar 2012 15:16:10 +0000 (11:16 -0400)
When we find a package in DIR/src/foo, we only let it
be known as foo if there is no other foo in an earlier
GOPATH directory or the GOROOT directory.
The GOROOT check was looking in GOROOT/src/foo
instead of GOROOT/src/pkg/foo, which meant that
the import paths "lib9", "libbio", "libmach", and so
on were unavailable, and the import paths "math",
"errors", and so on were available.  Correct this.

Fixes #3390.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/5927050

src/pkg/go/build/build.go

index 1c7c47231fd060864851194206ad6d9ab280c39d..d749aef15130d776a84e9ff5fd6bc57cc2575001 100644 (file)
@@ -387,7 +387,7 @@ func (ctxt *Context) Import(path string, srcDir string, mode ImportMode) (*Packa
                                // but check that using it wouldn't find something
                                // else first.
                                if ctxt.GOROOT != "" {
-                                       if dir := ctxt.joinPath(ctxt.GOROOT, "src", sub); ctxt.isDir(dir) {
+                                       if dir := ctxt.joinPath(ctxt.GOROOT, "src", "pkg", sub); ctxt.isDir(dir) {
                                                goto Found
                                        }
                                }