deps[path] = p1
imports = append(imports, p1)
for _, dep := range p1.deps {
- // 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 {
+ // The same import path could produce an error or not,
+ // depending on what tries to import it.
+ // Prefer to record entries with errors, so we can report them.
+ if deps[dep.ImportPath] == nil || dep.Error != nil {
deps[dep.ImportPath] = dep
}
}
}
}
exitIfErrors()
+
+ // Check for duplicate loads of the same package.
+ // That should be impossible, but if it does happen then
+ // we end up trying to build the same package twice,
+ // usually in parallel overwriting the same files,
+ // which doesn't work very well.
+ seen := map[string]bool{}
+ reported := map[string]bool{}
+ for _, pkg := range packageList(pkgs) {
+ if seen[pkg.ImportPath] && !reported[pkg.ImportPath] {
+ reported[pkg.ImportPath] = true
+ errorf("internal error: duplicate loads of %s", pkg.ImportPath)
+ }
+ seen[pkg.ImportPath] = true
+ }
+ exitIfErrors()
+
return pkgs
}
tg.run("get", "github.com/rsc/go-get-issue-11864")
tg.run("get", "-u", "github.com/rsc/go-get-issue-11864")
}
+
+func TestVendorCache(t *testing.T) {
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata/testvendor"))
+ tg.setenv("GO15VENDOREXPERIMENT", "1")
+ tg.runFail("build", "p")
+ tg.grepStderr("must be imported as x", "did not fail to build p")
+}