转自:http://www.jb51.net/article/61727.htm
在golang里执行windows下的命令行,例如在golang里面调用 del d:\a.txt 命令
package main import( "fmt" "os/exec" ) func main(){ c := exec.Command("cmd", "/C", "del", "D:\\a.txt") if err := c.Run(); err != nil { fmt.Println("Error: ", err) } }
时间: 2024-10-16 09:16:39