go 执行 shell 指令

shell.go

package main

import (
	"os/exec"
)

func exec_shell(s string) {
	exec.Command("/bin/bash", "-c", s).Run()
}

func main() {
	exec_shell("mkdir test")
}

go fmt shell.go

go build shell.go
./shell

猜你喜欢

转载自my.oschina.net/u/4038454/blog/2963898