The repo is template for other projects.
Here long repo description.
Get it from github:
go get -u https://github.com/gopowersupply/template
Documentation can be found here
This is examples section:
res, err := shell.Cmd("echo hi")
panic(err)
// res: hi
⚠️ Be aware that command result string truncates. This means that if the real output is' sample output\n'
you will get'sample output'
func ExecUnexpected() error {
// [...] Here your other returns with own errors
_, err := shell.Cmd("unexpected_command")
if err != nil {
return err
}
// [...] Here your other returns with own errors
}
func main() {
err := ExecUnexpected()
if shell.IsCommandError(err) {
// [...] to do anything
} else {
// [...] to do something other
}
}
And you can use errors.As(err, &shell.CommandError{})
as alternative.