From 81424fb000eaf1b6cd8c1d5bb4d476cb4b3b32db Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Sun, 21 Jun 2020 11:49:04 -0500 Subject: [PATCH] Fix windows compile errors. --- go.sum | 1 + widgets/proc_windows.go | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/go.sum b/go.sum index 59dcc337..4fe67f19 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,7 @@ github.com/distatus/battery v0.9.0 h1:8NS5o00/j3Oh2xgocA6pQROTp5guoR+s8CZlWzHC4Q github.com/distatus/battery v0.9.0/go.mod h1:gGO7GxHTi1zlRT+cAj8uGG0/8HFiqAeH0TJvoipnuPs= github.com/gizak/termui/v3 v3.1.0 h1:ZZmVDgwHl7gR7elfKf1xc4IudXZ5qqfDh4wExk4Iajc= github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY= +github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= diff --git a/widgets/proc_windows.go b/widgets/proc_windows.go index d34ef5ea..1d8bffc3 100644 --- a/widgets/proc_windows.go +++ b/widgets/proc_windows.go @@ -3,12 +3,13 @@ package widgets import ( "fmt" "log" + "strconv" - psProc "github.com/shirou/gopsutil/process" + "github.com/shirou/gopsutil/process" ) func getProcs() ([]Proc, error) { - psProcs, err := psProc.Processes() + psProcs, err := process.Processes() if err != nil { return nil, fmt.Errorf(tr.Value("widget.proc.err.gopsutil", err.Error())) } @@ -18,15 +19,24 @@ func getProcs() ([]Proc, error) { pid := psProc.Pid command, err := psProc.Name() if err != nil { - log.Println(tr.Value("widget.proc.err.getcmd", err, psProc, i, pid)) + sps := fmt.Sprintf("%v", psProc) + si := strconv.Itoa(i) + spid := fmt.Sprintf("%d", pid) + log.Println(tr.Value("widget.proc.err.getcmd", err.Error(), sps, si, spid)) } cpu, err := psProc.CPUPercent() if err != nil { - log.Println(tr.Value("widget.proc.err.cpupercent", err, psProc, i, pid)) + sps := fmt.Sprintf("%v", psProc) + si := strconv.Itoa(i) + spid := fmt.Sprintf("%d", pid) + log.Println(tr.Value("widget.proc.err.cpupercent", err.Error(), sps, si, spid)) } mem, err := psProc.MemoryPercent() if err != nil { - log.Println(tr.Value("widget.proc.err.mempercent", err, psProc, i, pid)) + sps := fmt.Sprintf("%v", psProc) + si := strconv.Itoa(i) + spid := fmt.Sprintf("%d", pid) + log.Println(tr.Value("widget.proc.err.mempercent", err.Error(), sps, si, spid)) } procs[i] = Proc{