make goctl work on linux

This commit is contained in:
kevin
2020-08-30 16:37:34 +08:00
parent 3c688c319e
commit 431be8ed9d
4 changed files with 9 additions and 3 deletions

View File

@@ -12,13 +12,14 @@ func Run(arg string) (string, error) {
goos := runtime.GOOS
var cmd *exec.Cmd
switch goos {
case "darwin":
case "darwin", "linux":
cmd = exec.Command("sh", "-c", arg)
case "windows":
cmd = exec.Command("cmd.exe", "/c", arg)
default:
return "", fmt.Errorf("unexpected os: %v", goos)
}
dtsout := new(bytes.Buffer)
stderr := new(bytes.Buffer)
cmd.Stdout = dtsout
@@ -30,5 +31,6 @@ func Run(arg string) (string, error) {
}
return "", err
}
return dtsout.String(), nil
}