vgo: let VGOROOT override GOROOT
diff --git a/vendor/cmd/go/internal/cfg/cfg.go b/vendor/cmd/go/internal/cfg/cfg.go
index c9039b6..56a3427 100644
--- a/vendor/cmd/go/internal/cfg/cfg.go
+++ b/vendor/cmd/go/internal/cfg/cfg.go
@@ -121,6 +121,9 @@
}
func findGOROOT() string {
+ if env := os.Getenv("VGOROOT"); env != "" {
+ return filepath.Clean(env)
+ }
if env := os.Getenv("GOROOT"); env != "" {
return filepath.Clean(env)
}
diff --git a/vendor/cmd/go/vgo_test.go b/vendor/cmd/go/vgo_test.go
new file mode 100644
index 0000000..a6ccd26
--- /dev/null
+++ b/vendor/cmd/go/vgo_test.go
@@ -0,0 +1,21 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package Main_test
+
+import (
+ "runtime"
+ "testing"
+)
+
+func TestVGOROOT(t *testing.T) {
+ tg := testgo(t)
+ defer tg.cleanup()
+
+ tg.setenv("GOROOT", "/bad")
+ tg.runFail("env")
+
+ tg.setenv("VGOROOT", runtime.GOROOT())
+ tg.run("env")
+}