mirror of
https://github.com/golang/go
synced 2024-11-19 02:04:42 -07:00
go/packages: give a better error if 'go' is missing
If we can't execute the go command, check to see if it exists. If it doesn't, say so in the error. Fixes golang/go#29552 Change-Id: Iffd2db5fc8f1daa2e458eaa326b27d9a0d971b6b Reviewed-on: https://go-review.googlesource.com/c/tools/+/168777 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
parent
86483bace6
commit
43e94f7338
@ -7,6 +7,7 @@ package packages
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/types"
|
"go/types"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -743,6 +744,11 @@ func invokeGo(cfg *Config, args ...string) (*bytes.Buffer, error) {
|
|||||||
// Catastrophic error:
|
// Catastrophic error:
|
||||||
// - executable not found
|
// - executable not found
|
||||||
// - context cancellation
|
// - context cancellation
|
||||||
|
|
||||||
|
// Check for executable not existing.
|
||||||
|
if _, err := exec.LookPath("go"); err != nil {
|
||||||
|
return nil, errors.New("'go list' driver requires 'go' to be installed")
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("couldn't exec 'go %v': %s %T", args, err, err)
|
return nil, fmt.Errorf("couldn't exec 'go %v': %s %T", args, err, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user