Skip to content

Commit 770314c

Browse files
committed
errs
1 parent f5ae30b commit 770314c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

utils/execute_command.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package utils
22

33
import (
44
"bufio"
5+
"bytes"
56
"fmt"
6-
"log"
77
"os/exec"
88
)
99

@@ -12,15 +12,14 @@ func ExecuteCmd(cmd *exec.Cmd, outputCallback func(string)) (string, error) {
1212
stdout, _ := cmd.StdoutPipe()
1313
//stderr, _ := cmd.StderrPipe()
1414

15-
log.Default()
15+
errorBytes := bytes.Buffer{}
16+
cmd.Stderr = &errorBytes
1617

1718
err := cmd.Start()
1819
if err != nil {
1920
return "", fmt.Errorf("start failed %s", err.Error())
2021
}
2122

22-
var errorString string
23-
2423
//go func() {
2524
// scanner := bufio.NewScanner(stderr)
2625
// scanner.Split(bufio.ScanLines)
@@ -43,7 +42,7 @@ func ExecuteCmd(cmd *exec.Cmd, outputCallback func(string)) (string, error) {
4342

4443
err = cmd.Wait()
4544
if err != nil {
46-
return "", fmt.Errorf("execution failed error: %s,\nmessage: %s", err.Error(), errorString)
45+
return "", fmt.Errorf("execution failed error: %s,\nmessage: %s", err.Error(), errorBytes.String())
4746
}
4847

4948
return result, err

0 commit comments

Comments
 (0)