Skip to content

Commit 5e7edb9

Browse files
authored
Merge pull request #52 from nao1215/improve-error-message-at-fail-update
Detailed error message when go install fails.
2 parents d4dfb16 + 82477c7 commit 5e7edb9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

internal/goutil/goutil.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package goutil
22

33
import (
4+
"bytes"
45
"fmt"
56
"go/build"
67
"os"
@@ -190,8 +191,14 @@ func Install(importPath string) error {
190191
if importPath == "command-line-arguments" {
191192
return errors.New("is devel-binary copied from local environment")
192193
}
193-
if err := exec.Command(goExe, "install", importPath+"@latest").Run(); err != nil {
194-
return fmt.Errorf("can't install %s: %w", importPath, err)
194+
195+
var stderr bytes.Buffer
196+
cmd := exec.Command(goExe, "install", importPath+"@latest")
197+
cmd.Stderr = &stderr
198+
199+
err := cmd.Run()
200+
if err != nil {
201+
return fmt.Errorf("can't install %s:\n%s", importPath, stderr.String())
195202
}
196203
return nil
197204
}

0 commit comments

Comments
 (0)