Skip to content

Instantly share code, notes, and snippets.

@xigang
Created May 4, 2016 07:53
Show Gist options
  • Select an option

  • Save xigang/9ae0280eee21ac1601d099c40e52d7e6 to your computer and use it in GitHub Desktop.

Select an option

Save xigang/9ae0280eee21ac1601d099c40e52d7e6 to your computer and use it in GitHub Desktop.
运行命令
package main
import "os/exec"
func main() {
app := "echo"
//app := "buah"
arg0 := "-e"
arg1 := "Hello world"
arg2 := "\n\tfrom"
arg3 := "golang"
cmd := exec.Command(app, arg0, arg1, arg2, arg3)
stdout, err := cmd.Output()
if err != nil {
println(err.Error())
return
}
print(string(stdout))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment