Golang: Determine a device major/minor number

While working on a monitoring agent for a service we will be introducing soon. I needed a way to determine the Major/Minor numbers for a device (e.g. /dev/mapper/datavg-srvlv).

It is actually much easier than I though. My first version as a gist.

But a much simpler solution exists, without using cgo.

stat := syscall.Stat_t{}
_ := syscall.Stat("/dev/sda", &stat)
fmt.Println("Major:",uint64(stat.Rdev/256), "Minor:",uint64(stat.Rdev%256))