cmd/go: add helpful error message when vcs is not found.

Fixes #4652.

R=bradfitz, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7094049
This commit is contained in:
Gustavo Franco 2013-01-29 08:20:43 -08:00 committed by Brad Fitzpatrick
parent aa0b573ad6
commit 56517aed95
1 changed files with 9 additions and 1 deletions

View File

@ -180,6 +180,14 @@ func (v *vcsCmd) run1(dir string, cmdline string, keyval []string, verbose bool)
args[i] = expand(m, arg)
}
_, err := exec.LookPath(v.cmd)
if err != nil {
fmt.Fprintf(os.Stderr,
"go: missing %s command. See http://golang.org/s/gogetcmd\n",
v.name)
return nil, err
}
cmd := exec.Command(v.cmd, args...)
cmd.Dir = dir
if buildX {
@ -189,7 +197,7 @@ func (v *vcsCmd) run1(dir string, cmdline string, keyval []string, verbose bool)
var buf bytes.Buffer
cmd.Stdout = &buf
cmd.Stderr = &buf
err := cmd.Run()
err = cmd.Run()
out := buf.Bytes()
if err != nil {
if verbose || buildV {