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

40 lines
769 B
Go

// +build windows
package devices
import (
psHost "github.com/shirou/gopsutil/v3/host"
)
func init() {
RegisterTemp(update)
RegisterDeviceList(Temperatures, devs, devs)
}
func update(temps map[string]int) map[string]error {
sensors, err := psHost.SensorsTemperatures()
if err != nil {
return map[string]error{"gopsutil": err}
}
for _, sensor := range sensors {
if _, ok := temps[sensor.SensorKey]; ok {
temps[sensor.SensorKey] = int(sensor.Temperature + 0.5)
}
}
return nil
}
func devs() []string {
sensors, err := psHost.SensorsTemperatures()
if err != nil {
return []string{}
}
rv := make([]string, 0, len(sensors))
for _, sensor := range sensors {
if sensor.Temperature != 0 {
rv = append(rv, sensor.SensorKey)
}
}
return rv
}