go语言调用cmd

package main

import (
	"fmt"
	"os/exec"
)

func main() {
    //删除C:UsersAdministratorDesktop目录下的index.html文件
	c := exec.Command("cmd", "/C", "del", "C:\Users\Administrator\Desktop\index.html")
	if err := c.Run(); err != nil {
		fmt.Println("Error: ", err)
	}
}
原文地址:https://www.cnblogs.com/zheng-chuang/p/6059289.html