If invoked 'go list' command fails, show its stderr.
Test: manual Change-Id: I776b71f8b6c6c3d46d60e790d944282efd6d55d7
This commit is contained in:
parent
ef4a5a3028
commit
d5fc469dd8
1 changed files with 7 additions and 4 deletions
|
@ -335,12 +335,15 @@ Usage: %s [--rewrite <pkg-prefix>=<replace>] [-exclude <package>] [-regen <file>
|
|||
}
|
||||
|
||||
cmd := exec.Command("go", "list", "-json", "./...")
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to dump the go packages: %v\n", err)
|
||||
var stdoutb, stderrb bytes.Buffer
|
||||
cmd.Stdout = &stdoutb
|
||||
cmd.Stderr = &stderrb
|
||||
if err := cmd.Run(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Running %q to dump the Go packages failed: %v, stderr:\n%s\n",
|
||||
cmd.String(), err, stderrb.Bytes())
|
||||
os.Exit(1)
|
||||
}
|
||||
decoder := json.NewDecoder(bytes.NewReader(output))
|
||||
decoder := json.NewDecoder(bytes.NewReader(stdoutb.Bytes()))
|
||||
|
||||
pkgs := []*GoPackage{}
|
||||
pkgMap := map[string]*GoPackage{}
|
||||
|
|
Loading…
Reference in a new issue