oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package creds
2
3import (
4 "time"
5
6 "golang.org/x/sys/unix"
7)
8
9// BootTime is when this Mac last booted (kern.boottime). No process
10// outlives a boot, so a launch begun before it has ended.
11func BootTime() (time.Time, error) {
12 tv, err := unix.SysctlTimeval("kern.boottime")
13 if err != nil {
14 return time.Time{}, err
15 }
16 return time.Unix(tv.Sec, int64(tv.Usec)*1000), nil
17}
18
19// BootID names this boot (kern.bootsessionuuid): a new value after every
20// boot, whatever the clock did.
21func BootID() (string, error) { return unix.Sysctl("kern.bootsessionuuid") }
22