package nmon import ( "fmt" "github.com/shirou/gopsutil/v4/cpu" "time" ) func Cpu() { go func() { flat, err := cpu.Percent(time.Second, false) if err != nil { return } fmt.Println(flat) }() flat, err := cpu.Percent(time.Second, true) if err != nil { return } c := 0.0000 for _, v := range flat { c += v } fmt.Println(flat) fmt.Println(c / float64(len(flat))) time.Sleep(time.Millisecond * 200) }