use Processor entry as model name fallback by @tmm1

pull/338/head
WAKAYAMA Shirou 8 years ago
parent 423a8ff2a6
commit a63f1aeeec

@ -108,6 +108,7 @@ func Info() ([]InfoStat, error) {
lines, _ := common.ReadLines(filename) lines, _ := common.ReadLines(filename)
var ret []InfoStat var ret []InfoStat
var processorName string
c := InfoStat{CPU: -1, Cores: 1} c := InfoStat{CPU: -1, Cores: 1}
for _, line := range lines { for _, line := range lines {
@ -119,6 +120,8 @@ func Info() ([]InfoStat, error) {
value := strings.TrimSpace(fields[1]) value := strings.TrimSpace(fields[1])
switch key { switch key {
case "Processor":
processorName = value
case "processor": case "processor":
if c.CPU >= 0 { if c.CPU >= 0 {
err := finishCPUInfo(&c) err := finishCPUInfo(&c)
@ -127,7 +130,7 @@ func Info() ([]InfoStat, error) {
} }
ret = append(ret, c) ret = append(ret, c)
} }
c = InfoStat{Cores: 1} c = InfoStat{Cores: 1, ModelName: processorName}
t, err := strconv.ParseInt(value, 10, 64) t, err := strconv.ParseInt(value, 10, 64)
if err != nil { if err != nil {
return ret, err return ret, err

Loading…
Cancel
Save