Simplify command execution on the shell even more to get you a one-liner with stdout/stderr capturing (/exec
)
Advanced topic, introduce a command/strategy patter to abstract if want to run a command locally/remote using ssh/on a docker container (/runnte/
)
See the examples at go-shell-cli-quickstarter
package mystuff
import (
"github.com/eugenmayer/go-exec/exec"
)
if stdout, stderr, err := exec.Run("echo hi", true); err != nil {
log.Print(stdout)
log.Print(stderr)
log.Fatal(err)
}
if stdout, stderr, err := exec.Run("echo ho", true); err != nil {
log.Print(stdout)
log.Print(stderr)
log.Fatal(err)
}
// continue..