cmd/go/internal/vgo: fix importDir bug

If we use "grpc.go4.org" as a import path, vgo will see it as a
standard import path, and try to find it in GOROOT.

Use search.IsStandardImportPath to fix it.

Fixes golang/go#25768

Change-Id: I1dfa50bdbdb15d989b729a06fa44550672523b1a
Reviewed-on: https://go-review.googlesource.com/117715
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Baokun Lee <nototon@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/vendor/cmd/go/internal/vgo/load.go b/vendor/cmd/go/internal/vgo/load.go
index ad5c6b8..67f878a 100644
--- a/vendor/cmd/go/internal/vgo/load.go
+++ b/vendor/cmd/go/internal/vgo/load.go
@@ -299,8 +299,7 @@
 		return dir
 	}
 
-	i := strings.Index(path, "/")
-	if i < 0 || !strings.Contains(path[:i], ".") {
+	if search.IsStandardImportPath(path) {
 		if strings.HasPrefix(path, "golang_org/") {
 			return filepath.Join(cfg.GOROOT, "src/vendor", path)
 		}
diff --git a/vendor/cmd/go/vgo_test.go b/vendor/cmd/go/vgo_test.go
index e13c7df..366e33c 100644
--- a/vendor/cmd/go/vgo_test.go
+++ b/vendor/cmd/go/vgo_test.go
@@ -669,3 +669,20 @@
 	tg.cd(tg.path("."))
 	tg.run("-vgo", "version")
 }
+
+func TestImportDir(t *testing.T) {
+	testenv.MustHaveExternalNetwork(t)
+	tg := testgo(t)
+	defer tg.cleanup()
+	tg.makeTempdir()
+
+	tg.setenv("GOPATH", tg.path("."))
+	tg.must(os.MkdirAll(tg.path("x"), 0777))
+	tg.must(ioutil.WriteFile(tg.path("x/main.go"), []byte(`
+		package x
+		import _ "goji.io"`), 0666))
+	tg.must(ioutil.WriteFile(tg.path("x/go.mod"), []byte("module x"), 0666))
+	tg.must(os.MkdirAll(filepath.Join(runtime.GOROOT(), "src", "goji.io"), 0777))
+	tg.cd(tg.path("x"))
+	tg.run("-vgo", "build")
+}