exec.Command 返回 “exit status 1” 获取详细错误信息

Jul 20, 2019 17:04 · 29 words · 1 minute read· views golang

cmd := exec.Command("find", "/", "-maxdepth", "1", "-exec", "wc", "-c", "{}", "\\")
output, err := cmd.CombinedOutput()
if err != nil {
    fmt.Println(fmt.Sprint(err) + ": " + string(output))
    return
}
fmt.Println(string(output))
tweet Share