xmtop/devices/cpu_linux.go
寻觅 9dcbd2a48e
Some checks failed
Build Go binaries / build (push) Has been cancelled
[修复] 更新依赖, 修复龙架构无法正常编译的问题
2024-09-13 15:08:35 +08:00

25 lines
384 B
Go

//go:build linux
// +build linux
package devices
import "github.com/shirou/gopsutil/v3/cpu"
func CpuCount() (int, error) {
cpuCount, err := cpu.Counts(false)
if err != nil {
return 0, err
}
if cpuCount == 0 {
is, err := cpu.Info()
if err != nil {
return 0, err
}
if is[0].Cores > 0 {
return len(is) / 2, nil
}
return len(is), nil
}
return cpuCount, nil
}