Files
wehub-resource-sync 36b3af2e3d
PR Check / Code Quality: Format (push) Failing after 1s
PR Check / Code Quality: Lint (darwin) (push) Failing after 0s
PR Check / Code Quality: Lint (freebsd) (push) Failing after 1s
PR Check / Code Quality: Lint (windows) (push) Failing after 1s
PR Check / Code Quality: Lint (linux) (push) Failing after 1s
PR Check / Security: Vulnerability Scan (push) Failing after 0s
Update Documentation / update-docs (push) Failing after 2s
PR Check / Code Quality: Vendor (push) Failing after 1s
PR Check / Code Quality: Coverage (push) Failing after 0s
PR Check / Tests: Unit (macos-latest) (push) Has been cancelled
PR Check / Tests: Unit (ubuntu-24.04) (push) Has been cancelled
PR Check / Tests: Unit (ubuntu-24.04-arm) (push) Has been cancelled
PR Check / Tests: Unit (windows-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:22:06 +08:00

39 lines
743 B
Go

//go:build darwin
package proc
import (
"os/exec"
"strconv"
"strings"
"time"
)
func bootTime() time.Time {
// Use sysctl kern.boottime on macOS
out, err := exec.Command("sysctl", "-n", "kern.boottime").Output()
if err != nil {
return time.Now()
}
// Output format: { sec = 1703123456, usec = 123456 } ...
outStr := string(out)
if idx := strings.Index(outStr, "sec = "); idx != -1 {
start := idx + 6
end := strings.Index(outStr[start:], ",")
if end != -1 {
secStr := outStr[start : start+end]
sec, err := strconv.ParseInt(strings.TrimSpace(secStr), 10, 64)
if err == nil {
return time.Unix(sec, 0)
}
}
}
return time.Now()
}
func ticksPerSecond() int {
return 100 // macOS default (same as Linux)
}