20 lines
269 B
Go
20 lines
269 B
Go
|
package utils
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"os/exec"
|
||
|
)
|
||
|
|
||
|
func ExecCmd(name string, args ...string) (string, error) {
|
||
|
cmd := exec.Command(name, args...)
|
||
|
var out bytes.Buffer
|
||
|
cmd.Stdout = &out
|
||
|
|
||
|
err := cmd.Run()
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
|
||
|
return out.String(), nil
|
||
|
}
|