go_sysutils/exec_extra/func.go
2020-09-26 02:17:33 -04:00

14 lines
252 B
Go

package exec_extra
import (
`os/exec`
)
func ExecCmdReturn(cmd *exec.Cmd) (exitStatus int, err error) {
// https://stackoverflow.com/a/55055100/733214
err = cmd.Run()
exitErr, _ := err.(*exec.ExitError)
exitStatus = exitErr.ExitCode()
return
}