package main import ( "fmt" "github.com/bitfield/script" "strings" ) func main() { fmt.Println("Hello World") commands := []string{"dateee", "man bogus"} for _, command := range commands { p := script.Exec(command) if errString := checkError(p); errString != "" { fmt.Println(strings.TrimSpace(errString)) } } } func checkError(p *script.Pipe) string { if p.Error() != nil { var outputError string outputError = p.Error().Error() if strings.Contains(outputError, "exit status") { p.SetError(nil) outputError, _ = p.String() } return outputError } return "" }