A simple package to execute shell commands on linux, darwin and windows.
$ go get -u github.com/SimonBaeumer/[email protected]
c := cmd.NewCommand("echo hello")
err := c.Execute()
if err != nil {
panic(err.Error())
}
fmt.Println(c.Stdout())
fmt.Println(c.Stderr())
c := cmd.NewCommand("echo hello", cmd.WithStandardStreams)
c.Execute()
func SetTimeout(c *Command) {
c.Timeout = 1 * time.Hour
}
func SetWorkingDir(c *Command) {
c.WorkingDir = "/tmp/test"
}
c := cmd.NewCommand("pwd", SetTimeout, SetWorkingDir)
c.Execute()
make test
- os.Stdout and os.Stderr output access after execution via
c.Stdout()
andc.Stderr()