mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-20 23:46:23 +01:00
8b7917cd81
See https://tip.golang.org/doc/go1.17#gofmt for more details
24 lines
496 B
Go
24 lines
496 B
Go
//go:build darwin || freebsd || openbsd || dragonfly || netbsd
|
|
// +build darwin freebsd openbsd dragonfly netbsd
|
|
|
|
package memory
|
|
|
|
import (
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
// This has been adapted from github.com/pbnjay/memory.
|
|
func sysctlUint64(name string) (uint64, error) {
|
|
s, err := syscall.Sysctl(name)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
// hack because the string conversion above drops a \0
|
|
b := []byte(s)
|
|
if len(b) < 8 {
|
|
b = append(b, 0)
|
|
}
|
|
return *(*uint64)(unsafe.Pointer(&b[0])), nil
|
|
}
|