package sys
import "syscall"
func syscallToErrno(err error ) (Errno , bool ) {
errno , ok := err .(syscall .Errno )
if !ok {
return 0 , false
}
switch errno {
case 0 :
return 0 , true
case syscall .EACCES :
return EACCES , true
case syscall .EAGAIN :
return EAGAIN , true
case syscall .EBADF :
return EBADF , true
case syscall .EEXIST :
return EEXIST , true
case syscall .EFAULT :
return EFAULT , true
case syscall .EINTR :
return EINTR , true
case syscall .EINVAL :
return EINVAL , true
case syscall .EIO :
return EIO , true
case syscall .EISDIR :
return EISDIR , true
case syscall .ELOOP :
return ELOOP , true
case syscall .ENAMETOOLONG :
return ENAMETOOLONG , true
case syscall .ENOENT :
return ENOENT , true
case syscall .ENOSYS :
return ENOSYS , true
case syscall .ENOTDIR :
return ENOTDIR , true
case syscall .ERANGE :
return ERANGE , true
case syscall .ENOTEMPTY :
return ENOTEMPTY , true
case syscall .ENOTSOCK :
return ENOTSOCK , true
case syscall .ENOTSUP :
return ENOTSUP , true
case syscall .EPERM :
return EPERM , true
case syscall .EROFS :
return EROFS , true
default :
return EIO , true
}
}
func (e Errno ) Unwrap () error {
switch e {
case 0 :
return nil
case EACCES :
return syscall .EACCES
case EAGAIN :
return syscall .EAGAIN
case EBADF :
return syscall .EBADF
case EEXIST :
return syscall .EEXIST
case EFAULT :
return syscall .EFAULT
case EINTR :
return syscall .EINTR
case EINVAL :
return syscall .EINVAL
case EIO :
return syscall .EIO
case EISDIR :
return syscall .EISDIR
case ELOOP :
return syscall .ELOOP
case ENAMETOOLONG :
return syscall .ENAMETOOLONG
case ENOENT :
return syscall .ENOENT
case ENOSYS :
return syscall .ENOSYS
case ENOTDIR :
return syscall .ENOTDIR
case ENOTEMPTY :
return syscall .ENOTEMPTY
case ENOTSOCK :
return syscall .ENOTSOCK
case ENOTSUP :
return syscall .ENOTSUP
case EPERM :
return syscall .EPERM
case EROFS :
return syscall .EROFS
default :
return syscall .EIO
}
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .