package creds import ( "time" "golang.org/x/sys/unix" ) // BootTime is when this Mac last booted (kern.boottime). No process // outlives a boot, so a launch begun before it has ended. func BootTime() (time.Time, error) { tv, err := unix.SysctlTimeval("kern.boottime") if err != nil { return time.Time{}, err } return time.Unix(tv.Sec, int64(tv.Usec)*1000), nil } // BootID names this boot (kern.bootsessionuuid): a new value after every // boot, whatever the clock did. func BootID() (string, error) { return unix.Sysctl("kern.bootsessionuuid") }