The build list is very incomplete in vendor mode,
so we can't rely on it in general.
findModule may be called in modload.PackageModuleInfo, which
load.LoadImport invokes relatively early during a build.
Before this change, the accompanying test failed at 'go build
-mod=vendor' with the message:
build diamondpoint: cannot find module for path diamondpoint
Change-Id: I5e667d8e406872be703510afeb079f6cbfdbd3c8
Reviewed-on: https://go-review.googlesource.com/c/140861
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
if path == "." {
return buildList[0]
}
+ if cfg.BuildMod == "vendor" {
+ readVendorList()
+ return vendorMap[path]
+ }
for _, mod := range buildList {
if maybeInModule(path, mod.Path) {
return mod
require (
a v1.0.0
+ diamondroot v0.0.0
mysite/myname/mypkg v1.0.0
w v1.0.0 // indirect
x v1.0.0
replace (
a v1.0.0 => ./a
+ diamondleft => ./diamondleft
+ diamondpoint => ./diamondpoint
+ diamondright => ./diamondright
+ diamondroot => ./diamondroot
mysite/myname/mypkg v1.0.0 => ./mypkg
w v1.0.0 => ./w
x v1.0.0 => ./x
package m
import _ "x/x1"
+-- importdiamond.go --
+package m
+
+import _ "diamondroot"
-- w/go.mod --
module w
-- w/w.go --
module z
-- z/z.go --
package z
+
+-- diamondroot/go.mod --
+module diamondroot
+
+require (
+ diamondleft v0.0.0
+ diamondright v0.0.0
+)
+-- diamondroot/x.go --
+package diamondroot
+
+import (
+ _ "diamondleft"
+ _ "diamondright"
+)
+-- diamondleft/go.mod --
+module diamondleft
+
+require (
+ diamondpoint v0.0.0
+)
+-- diamondleft/x.go --
+package diamondleft
+
+import _ "diamondpoint"
+-- diamondright/go.mod --
+module diamondright
+
+require (
+ diamondpoint v0.0.0
+)
+-- diamondright/x.go --
+package diamondright
+
+import _ "diamondpoint"
+-- diamondpoint/go.mod --
+module diamondpoint
+-- diamondpoint/x.go --
+package diamondpoint