oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package runner
2
3import (
4 "time"
5
6 "golang.org/x/sys/unix"
7)
8
9// hostClock on macOS: the monotonic clock that keeps counting in sleep
10// and the boot session's UUID.
11type hostClock struct{}
12
13func (hostClock) Read() (ClockReading, error) {
14 var ts unix.Timespec
15 if err := unix.ClockGettime(unix.CLOCK_MONOTONIC, &ts); err != nil {
16 return ClockReading{}, err
17 }
18 boot, err := unix.Sysctl("kern.bootsessionuuid")
19 if err != nil {
20 return ClockReading{}, err
21 }
22 return ClockReading{Wall: time.Now(), Elapsed: time.Duration(ts.Nano()), BootID: boot}, nil
23}
24