summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2019-03-11 22:52:37 -0700
committerCaleb Bassi <calebjbassi@gmail.com>2019-03-11 23:02:45 -0700
commitade4f2a623094ba7db945d225e2b4c4af57e1320 (patch)
treebf973eb4469f81778221a54fc5274a9845649f57
parentd38fd3a5753ab1774ace35f4a558d7b1bc6039b0 (diff)
Minor refactor
-rw-r--r--src/widgets/proc.go8
-rw-r--r--src/widgets/proc_windows.go10
2 files changed, 9 insertions, 9 deletions
diff --git a/src/widgets/proc.go b/src/widgets/proc.go
index 06e840c..fcece34 100644
--- a/src/widgets/proc.go
+++ b/src/widgets/proc.go
@@ -37,7 +37,7 @@ type Proc struct {
type ProcWidget struct {
*ui.Table
- cpuCount float64
+ cpuCount int
updateInterval time.Duration
sortMethod ProcSortMethod
groupedProcs []Proc
@@ -53,7 +53,7 @@ func NewProcWidget() *ProcWidget {
self := &ProcWidget{
Table: ui.NewTable(),
updateInterval: time.Second,
- cpuCount: float64(cpuCount),
+ cpuCount: cpuCount,
sortMethod: ProcSortCpu,
showGroupedProcs: true,
}
@@ -92,9 +92,9 @@ func (self *ProcWidget) update() {
return
}
- // can't iterate on the entries directly since we can't modify them that way
+ // have to iterate over the entry number in order to modify the array in place
for i := range procs {
- procs[i].Cpu /= self.cpuCount
+ procs[i].Cpu /= float64(self.cpuCount)
}
self.ungroupedProcs = procs
diff --git a/src/widgets/proc_windows.go b/src/widgets/proc_windows.go
index 1363c22..adc49e9 100644
--- a/src/widgets/proc_windows.go
+++ b/src/widgets/proc_windows.go
@@ -30,13 +30,13 @@ func getProcs() ([]Proc, error) {
}
procs[i] = Proc{
- int(pid),
- command,
- cpu / self.cpuCount,
- float64(mem),
+ Pid: int(pid),
+ CommandName: command,
+ Cpu: cpu,
+ Mem: float64(mem),
// getting command args using gopsutil's Cmdline and CmdlineSlice wasn't
// working the last time I tried it, so we're just reusing 'command'
- command,
+ FullCommand: command,
}
}