2 Star 14 Fork 16

王布衣/engine

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
shell.go 546 Bytes
Copy Edit Raw Blame History
package utils
import (
"bytes"
"errors"
"io/ioutil"
"os/exec"
"strings"
"syscall"
)
func shell(bin string, args ...string) (string, error) {
var out bytes.Buffer
cmd := exec.Command(bin, args...)
cmd.Stdout = &out
cmd.Stderr = ioutil.Discard
err := cmd.Run()
var exitError *exec.ExitError
if errors.As(err, &exitError) {
if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); ok {
if waitStatus.ExitStatus() != 0 {
return "", err
}
}
}
return strings.TrimRight(strings.TrimSpace(out.String()), "\000"), nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v1.9.5

Search