git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/sysinfo/kernel_linux.go (about) 1 // Copyright © 2016 Zlatko Čalušić 2 // 3 // Use of this source code is governed by an MIT-style license that can be found in the LICENSE file. 4 5 //go:build linux 6 // +build linux 7 8 package sysinfo 9 10 import ( 11 "strings" 12 "syscall" 13 "unsafe" 14 ) 15 16 // Kernel information. 17 type Kernel struct { 18 Release string `json:"release,omitempty"` 19 Version string `json:"version,omitempty"` 20 Architecture string `json:"architecture,omitempty"` 21 } 22 23 func (si *SysInfo) getKernelInfo() { 24 si.Kernel.Release = slurpFile("/proc/sys/kernel/osrelease") 25 si.Kernel.Version = slurpFile("/proc/sys/kernel/version") 26 27 var uname syscall.Utsname 28 if err := syscall.Uname(&uname); err != nil { 29 return 30 } 31 32 si.Kernel.Architecture = strings.TrimRight(string((*[65]byte)(unsafe.Pointer(&uname.Machine))[:]), "\000") 33 }