From 7889ce3e03c795d73fb0e9acdfd22adbe9f45d72 Mon Sep 17 00:00:00 2001 From: mayowa Date: Tue, 25 Aug 2015 22:21:10 -0700 Subject: [PATCH] changed ProccessorId type to *string, cause wmi sometimes returns nil for it --- cpu/cpu_windows.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cpu/cpu_windows.go b/cpu/cpu_windows.go index d0e93c0..d148ee4 100644 --- a/cpu/cpu_windows.go +++ b/cpu/cpu_windows.go @@ -19,7 +19,7 @@ type Win32_Processor struct { Manufacturer string Name string NumberOfLogicalProcessors uint32 - ProcessorId string + ProcessorId *string Stepping *string MaxClockSpeed uint32 } @@ -62,14 +62,17 @@ func CPUInfo() ([]CPUInfoStat, error) { if err != nil { return ret, err } - for i, l := range dst { + + procID := "" + + for i, l := range dst { cpu := CPUInfoStat{ CPU: int32(i), Family: fmt.Sprintf("%d", l.Family), VendorID: l.Manufacturer, ModelName: l.Name, Cores: int32(l.NumberOfLogicalProcessors), - PhysicalID: l.ProcessorId, + PhysicalID: procID, Mhz: float64(l.MaxClockSpeed), Flags: []string{}, }