vgo: fix Go 1.9 check What matters is the GOROOT source tree we are using, not the version of Go that built the vgo binary. Also the old version check was too late: vgo would have already failed due to having the wrong source tree. Fixes golang/go#24694. Change-Id: I62f5affa59777884eea40a8f1850de4f618d8c2b Reviewed-on: https://go-review.googlesource.com/104975 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/main.go b/main.go index 86cba76..c956185 100644 --- a/main.go +++ b/main.go
@@ -25,24 +25,8 @@ // package main -import ( - Main "cmd/go" - "go/build" - "log" -) +import Main "cmd/go" func main() { - checkGoVersion() - Main.Main() } - -func checkGoVersion() { - for _, tag := range build.Default.ReleaseTags { - if tag == "go1.10" { - return - } - } - log.SetFlags(0) - log.Fatalf("vgo requires Go 1.10") -}
diff --git a/vendor/cmd/go/internal/cfg/cfg.go b/vendor/cmd/go/internal/cfg/cfg.go index 56a3427..5093c28 100644 --- a/vendor/cmd/go/internal/cfg/cfg.go +++ b/vendor/cmd/go/internal/cfg/cfg.go
@@ -11,6 +11,7 @@ "fmt" "go/build" "io/ioutil" + "log" "os" "path/filepath" "runtime" @@ -121,6 +122,16 @@ } func findGOROOT() string { + goroot := findGOROOT1() + _, err := os.Stat(filepath.Join(goroot, "api/go1.10.txt")) + if err != nil { + log.SetFlags(0) + log.Fatalf("vgo requires Go 1.10 but VGOROOT=%s is not a Go 1.10 source tree", goroot) + } + return goroot +} + +func findGOROOT1() string { if env := os.Getenv("VGOROOT"); env != "" { return filepath.Clean(env) }