Let's say I try to acquire a lock, fail, and want to exit the program.
err = syscall.Flock(lockfd, syscall.LOCK_EX|syscall.LOCK_NB)
if err == syscall.EAGAIN {
os.Exit(err)
}
The problem is you need to pass an integer to os.Exit.
I've tried:
os.Exit(int(err))
os.Exit(syscall.EAGAIN)
// Compiles fine, but the cast fails.. no idea why
eerr, _ := err.(*syscall.Errno); os.Exit(int(*eerr))
// panics
reflect.ValueOf(err).Int()
It seems like you can compare the syscall.Errno to other integers, but actually trying to get the value of it is escaping me...