From bde422a2ff956cb0c16ac40887809df470f0278d Mon Sep 17 00:00:00 2001 From: shirou Date: Sat, 4 Dec 2021 04:23:33 +0000 Subject: [PATCH] [cpu][mac] doesn't return error when cpu.frequency --- cpu/cpu_darwin.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cpu/cpu_darwin.go b/cpu/cpu_darwin.go index 4c81e1b..9f3988b 100644 --- a/cpu/cpu_darwin.go +++ b/cpu/cpu_darwin.go @@ -87,10 +87,9 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { // Use the rated frequency of the CPU. This is a static value and does not // account for low power or Turbo Boost modes. cpuFrequency, err := unix.SysctlUint64("hw.cpufrequency") - if err != nil { - return ret, err + if err == nil { + c.Mhz = float64(cpuFrequency) / 1000000.0 } - c.Mhz = float64(cpuFrequency) / 1000000.0 return append(ret, c), nil }