From ade4f2a623094ba7db945d225e2b4c4af57e1320 Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Mon, 11 Mar 2019 22:52:37 -0700 Subject: [PATCH] Minor refactor --- src/widgets/proc.go | 8 ++++---- src/widgets/proc_windows.go | 10 +++++----- 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, } }