//go:build linux package hostexec import ( "golang.org/x/sys/unix" "os" "strings" "time" ) type SystemClock struct{} func (SystemClock) Now() (time.Time, int64, error) { var ts unix.Timespec if err := unix.ClockGettime(unix.CLOCK_BOOTTIME, &ts); err != nil { return time.Time{}, 0, err } return time.Now(), ts.Nano(), nil } func (SystemClock) After(d time.Duration) <-chan time.Time { return time.After(d) } func BootID() (string, error) { b, err := os.ReadFile("/proc/sys/kernel/random/boot_id") if err != nil { return "", err } id := strings.TrimSpace(string(b)) if !validID(id) { return "", ErrState } return id, nil }