1
0
mirror of https://github.com/golang/go synced 2024-09-24 23:20:12 -06:00

cmd/go: check GOROOT directory is present before acting

Fixes #5042.

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/7786047
This commit is contained in:
Alex Brainman 2013-05-23 14:13:02 +10:00
parent 4b2eb3f9f8
commit d67e300f28

View File

@ -144,6 +144,11 @@ func main() {
}
}
if fi, err := os.Stat(goroot); err != nil || !fi.IsDir() {
fmt.Fprintf(os.Stderr, "go: cannot find GOROOT directory: %v\n", goroot)
os.Exit(2)
}
for _, cmd := range commands {
if cmd.Name() == args[0] && cmd.Run != nil {
cmd.Flag.Usage = func() { cmd.Usage() }