GetErrno checks if the Go error is a kernel errno.
(err error)
| 10 | |
| 11 | // GetErrno checks if the Go error is a kernel errno. |
| 12 | func GetErrno(err error) (iserrno bool, errno error) { |
| 13 | var sysErr *os.SyscallError |
| 14 | if errors.As(err, &sysErr) { |
| 15 | return true, sysErr.Err |
| 16 | } |
| 17 | |
| 18 | var pathErr *os.PathError |
| 19 | if errors.As(err, &pathErr) { |
| 20 | return true, pathErr.Err |
| 21 | } |
| 22 | |
| 23 | var tmpErrno unix.Errno |
| 24 | if errors.As(err, &tmpErrno) { |
| 25 | return true, tmpErrno |
| 26 | } |
| 27 | |
| 28 | return false, nil |
| 29 | } |
| 30 | |
| 31 | // ExitStatus extracts the exit status from the error returned by exec.Cmd. |
| 32 | // If a nil err is provided then an exit status of 0 is returned along with the nil error. |
no outgoing calls
no test coverage detected
searching dependent graphs…