package main import ( "fmt" "unsafe" "golang.org/x/sys/unix" ) const ( RNDGETENTCNT int = 0x80045200 ) func main() { var ( fd int err error ) if fd, err = unix.Open("/dev/random", unix.O_RDONLY, 0); err != nil { fmt.Printf("Error: %v\n", err) } defer unix.Close(fd) var ( ent int ) _, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(fd), uintptr(RNDGETENTCNT), uintptr(unsafe.Pointer(&ent))) if errno != 0 { fmt.Printf("Error: %v\n", errno) } fmt.Printf("Available Entropy: %v\n", ent) }