File: sysutil_bsd.go

package info (click to toggle)
golang-github-chromedp-sysutil 1.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 112 kB
  • sloc: makefile: 5
file content (26 lines) | stat: -rw-r--r-- 444 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// +build darwin freebsd openbsd netbsd

package sysutil

import (
	"bytes"
	"encoding/binary"
	"syscall"
	"time"
)

func init() {
	// get boot time
	res, err := syscall.Sysctl("kern.boottime")
	if err != nil {
		btime = time.Now()
		return
	}
	// decode
	var t timeval
	if err = binary.Read(bytes.NewBuffer([]byte(res)), binary.LittleEndian, &t); err != nil {
		btime = time.Now()
		return
	}
	btime = time.Unix(int64(t.Sec), int64(t.Usec))
}