mirror of
https://github.com/EnumeratedDev/stormfetch.git
synced 2026-09-16 07:56:12 +00:00
Improve 'cpus' module
This commit is contained in:
+16
-3
@@ -10,7 +10,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type CPU struct {
|
type CPU struct {
|
||||||
Vendor string
|
|
||||||
Model string
|
Model string
|
||||||
Cores int
|
Cores int
|
||||||
Threads int
|
Threads int
|
||||||
@@ -44,9 +43,23 @@ func GetCPUs(hiddenCPUs []int) []CPU {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove unnecessary information from the CPU model
|
||||||
|
model := cpu.Model
|
||||||
|
stringsToRemove := []string{
|
||||||
|
" CPU", " FPU", " APU", " Processor",
|
||||||
|
" Dual-Core", " Quad-Core", " Six-Core", " Eight-Core", " Ten-Core",
|
||||||
|
" 2-Core", " 4-Core", " 6-Core", " 8-Core", " 10-Core", " 12-Core", " 14-Core", " 16-Core",
|
||||||
|
}
|
||||||
|
for _, str := range stringsToRemove {
|
||||||
|
model = strings.ReplaceAll(model, str, "")
|
||||||
|
}
|
||||||
|
model = strings.Split(model, "w/ Radeon ")[0]
|
||||||
|
model = strings.Split(model, "with Radeon ")[0]
|
||||||
|
model = strings.Split(model, "@")[0]
|
||||||
|
model = strings.TrimSpace(model)
|
||||||
|
|
||||||
ret = append(ret, CPU{
|
ret = append(ret, CPU{
|
||||||
Vendor: cpu.Vendor,
|
Model: model,
|
||||||
Model: cpu.Model,
|
|
||||||
Cores: int(cpu.NumCores),
|
Cores: int(cpu.NumCores),
|
||||||
Threads: int(cpu.NumThreads),
|
Threads: int(cpu.NumThreads),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -200,8 +200,6 @@ func initializeModuleMap() {
|
|||||||
switch s {
|
switch s {
|
||||||
case "CPU_NUM":
|
case "CPU_NUM":
|
||||||
return strconv.Itoa(i + 1)
|
return strconv.Itoa(i + 1)
|
||||||
case "CPU_VENDOR":
|
|
||||||
return cpu.Vendor
|
|
||||||
case "CPU_MODEL":
|
case "CPU_MODEL":
|
||||||
return cpu.Model
|
return cpu.Model
|
||||||
case "CPU_CORES":
|
case "CPU_CORES":
|
||||||
|
|||||||
Reference in New Issue
Block a user