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 "os"
5 "strings"
6 "time"
7
8 "golang.org/x/sys/unix"
9)
10
11type hostClock struct{}
12
13func (hostClock) Read() (ClockReading, error) {
14 var ts unix.Timespec
15 if err := unix.ClockGettime(unix.CLOCK_BOOTTIME, &ts); err != nil {
16 return ClockReading{}, err
17 }
18 b, err := os.ReadFile("/proc/sys/kernel/random/boot_id")
19 if err != nil {
20 return ClockReading{}, err
21 }
22 return ClockReading{Wall: time.Now(), Elapsed: time.Duration(ts.Nano()), BootID: strings.TrimSpace(string(b))}, nil
23}
24