I\'m using the package: os/exec http://golang.org/pkg/os/exec/ to execute a command in the operating system but I don\'t seem to find the way to get the exit code. I can rea
Since golang version 1.12, the exit code is available natively and in a cross-platform manner. See ExitError and ExitCode().
ExitCode returns the exit code of the exited process, or -1 if the process hasn't exited or was terminated by a signal.
if err := cmd.Run() ; err != nil {
if exitError, ok := err.(*exec.ExitError); ok {
return exitError.ExitCode()
}
}