shirou_gopsutil/host/host_posix.go

17 lines
340 B
Go
Raw Normal View History

2021-12-23 05:54:41 +08:00
//go:build linux || freebsd || openbsd || darwin || solaris
// +build linux freebsd openbsd darwin solaris
package host
import (
2019-08-13 04:32:14 +08:00
"bytes"
"golang.org/x/sys/unix"
)
2020-09-11 19:51:20 +08:00
func KernelArch() (string, error) {
var utsname unix.Utsname
err := unix.Uname(&utsname)
2019-08-13 04:32:14 +08:00
return string(utsname.Machine[:bytes.IndexByte(utsname.Machine[:], 0)]), err
}