golang中os/exec包用法
exec包执行外部命令,它将os.StartProcess进行包装使得它更容易映射到stdin和stdout,并且利用pipe连接i/o. func LookPath(file string) (string, error) //LookPath在环境变量中查找科执行二进制文件,如果file中包含一个斜杠,则直接根据绝对路径或者相对本目录的相对路径去查找 func main() { f, err := exec.LookPath("ls") if err != nil { fmt.Println(err) } fmt.Println(f) // /bin/ls } type Cmd //表示一个正在准备或者正在运行的外部命令 type Cmd struct { Path string //运...阅读全文