Skip to content

Commit

Permalink
cmd/go: check GOROOT directory is present before acting
Browse files Browse the repository at this point in the history
Fixes #5042.

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/7786047
  • Loading branch information
alexbrainman committed May 23, 2013
1 parent 4b2eb3f commit d67e300
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cmd/go/main.go
Expand Up @@ -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() }
Expand Down

0 comments on commit d67e300

Please sign in to comment.