使用案例代码:
package main import ( "bytes" "fmt" "log" "os/exec" ) func main() { cmd := exec.Command("php", "D:/baiduyun/command/application/cli", "read") var out bytes.Buffer cmd.Stdout = &out err := cmd.Start() if err != nil { log.Fatal(err) } log.Printf("Waiting for command to finish...") fmt.Println(cmd.Args) err = cmd.Wait() if err != nil { log.Printf("Command finished with error: %v", err) } fmt.Println(out.String()) }
有疑问加站长微信联系(非本文作者)