Skip to content

Commit 9c1bf12

Browse files
nwykesJanDeDobbeleer
authored andcommitted
refactor: swap go-ps for gopsutil
1 parent 9379c99 commit 9c1bf12

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

environment.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"strings"
1313

1414
"github.com/distatus/battery"
15-
ps "github.com/mitchellh/go-ps"
1615
"github.com/shirou/gopsutil/host"
16+
"github.com/shirou/gopsutil/process"
1717
)
1818

1919
type environmentInfo interface {
@@ -173,12 +173,12 @@ func (env *environment) getBatteryInfo() (*battery.Battery, error) {
173173

174174
func (env *environment) getShellName() string {
175175
pid := os.Getppid()
176-
p, err := ps.FindProcess(pid)
177-
176+
p, _ := process.NewProcess(int32(pid))
177+
name, err := p.Name()
178178
if err != nil {
179179
return "unknown"
180180
}
181-
shell := strings.Replace(p.Executable(), ".exe", "", 1)
181+
shell := strings.Replace(name, ".exe", "", 1)
182182
return strings.Trim(shell, " ")
183183
}
184184

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ require (
77
github.com/distatus/battery v0.10.1-0.20200722221337-7e1bf2bbb15c
88
github.com/go-ole/go-ole v1.2.4 // indirect
99
github.com/gookit/color v1.3.1
10-
github.com/mitchellh/go-ps v1.0.0
1110
github.com/shirou/gopsutil v2.20.9+incompatible
1211
github.com/stretchr/objx v0.3.0 // indirect
1312
github.com/stretchr/testify v1.6.1

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ github.com/JanDeDobbeleer/battery v0.10.1-0.20200909080331-bb0a7566dbb8 h1:+SZ7q
22
github.com/JanDeDobbeleer/battery v0.10.1-0.20200909080331-bb0a7566dbb8/go.mod h1:STnSvFLX//eEpkaN7qWRxCWxrWOcssTDgnG4yqq9BRE=
33
github.com/JanDeDobbeleer/color v1.3.1-0.20201014085303-5ffcdf66388a h1:0gU8YI1Z9jXOeMbUxRQR6/XznZTKXSQcVuoFZtbrkN8=
44
github.com/JanDeDobbeleer/color v1.3.1-0.20201014085303-5ffcdf66388a/go.mod h1:R3ogXq2B9rTbXoSHJ1HyUVAZ3poOJHpd9nQmyGZsfvQ=
5-
github.com/JanDeDobbeleer/go-ps v1.0.0 h1:3nqwUNAIzjrjQoEdZDVcS5OCm+KIoShKnANJ5xfkgBY=
6-
github.com/JanDeDobbeleer/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
75
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
86
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
97
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

0 commit comments

Comments
 (0)