xmtop/devices/temp.go
Sean E. Russell 7a89225d72 Abstracts CPU & mem devices.
Finishes device refactoring: temps

Refactoring to allow updating maps. Simpler, and optimizable.
2020-02-28 07:06:51 -06:00

23 lines
414 B
Go

package devices
import (
"log"
)
var tempUpdates []func(map[string]int) map[string]error
func RegisterTemp(update func(map[string]int) map[string]error) {
tempUpdates = append(tempUpdates, update)
}
func UpdateTemps(temps map[string]int) {
for _, f := range tempUpdates {
errs := f(temps)
if errs != nil {
for k, e := range errs {
log.Printf("error updating temp for %s: %s", k, e)
}
}
}
}