]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix missing internal import error
authorRuss Cox <rsc@golang.org>
Tue, 21 Jul 2015 00:05:37 +0000 (20:05 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 22 Jul 2015 17:33:18 +0000 (17:33 +0000)
Fixes #11331.

Change-Id: I19b8172421044c301bc136fc8f7bfdadbf880e25
Reviewed-on: https://go-review.googlesource.com/12450
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
src/cmd/go/go_test.go
src/cmd/go/pkg.go
src/cmd/go/testdata/testinternal4/src/p/p.go [new file with mode: 0644]
src/cmd/go/testdata/testinternal4/src/q/internal/x/x.go [new file with mode: 0644]
src/cmd/go/testdata/testinternal4/src/q/j/j.go [new file with mode: 0644]

index 147917c46fd2ded2804fc151080fc808833e1c1a..c169ec7db87fb46195ab453e9b9d21f50ddfc73f 100644 (file)
@@ -967,6 +967,14 @@ func TestInternalPackageErrorsAreHandled(t *testing.T) {
        tg.run("list", "./testdata/testinternal3")
 }
 
+func TestInternalCache(t *testing.T) {
+       tg := testgo(t)
+       defer tg.cleanup()
+       tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata/testinternal4"))
+       tg.runFail("build", "p")
+       tg.grepStderr("internal", "did not fail to build p")
+}
+
 func TestMoveGit(t *testing.T) {
        testMove(t, "git", "rsc.io/pdf", "pdf", "rsc.io/pdf/.git/config")
 }
index e6c17036feb58f92f4ec720773393bcbcc2e882c..95b5eb347af2e08a8d381b3a6f0097507b97dc56 100644 (file)
@@ -882,7 +882,13 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package
                deps[path] = p1
                imports = append(imports, p1)
                for _, dep := range p1.deps {
-                       deps[dep.ImportPath] = dep
+                       // Do not overwrite entries installed by direct import
+                       // just above this loop. Those have stricter constraints
+                       // about internal and vendor visibility and may contain
+                       // errors that we need to preserve.
+                       if deps[dep.ImportPath] == nil {
+                               deps[dep.ImportPath] = dep
+                       }
                }
                if p1.Incomplete {
                        p.Incomplete = true
diff --git a/src/cmd/go/testdata/testinternal4/src/p/p.go b/src/cmd/go/testdata/testinternal4/src/p/p.go
new file mode 100644 (file)
index 0000000..6bdee27
--- /dev/null
@@ -0,0 +1,6 @@
+package p
+
+import (
+       _ "q/internal/x"
+       _ "q/j"
+)
diff --git a/src/cmd/go/testdata/testinternal4/src/q/internal/x/x.go b/src/cmd/go/testdata/testinternal4/src/q/internal/x/x.go
new file mode 100644 (file)
index 0000000..823aafd
--- /dev/null
@@ -0,0 +1 @@
+package x
diff --git a/src/cmd/go/testdata/testinternal4/src/q/j/j.go b/src/cmd/go/testdata/testinternal4/src/q/j/j.go
new file mode 100644 (file)
index 0000000..9f07543
--- /dev/null
@@ -0,0 +1,3 @@
+package j
+
+import _ "q/internal/x"