Skip to content

Commit e4b0a1e

Browse files
authored
dev: remove archived mitchellh/go-ps (#5211)
1 parent a27f475 commit e4b0a1e

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ require (
7878
github.com/mattn/go-colorable v0.1.13
7979
github.com/mgechev/revive v1.5.1
8080
github.com/mitchellh/go-homedir v1.1.0
81-
github.com/mitchellh/go-ps v1.0.0
8281
github.com/moricho/tparallel v0.3.2
8382
github.com/nakabonne/nestif v0.3.1
8483
github.com/nishanths/exhaustive v0.12.0

go.sum

-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/bench/bench_test.go

+16-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"testing"
1616
"time"
1717

18-
gops "github.com/mitchellh/go-ps"
1918
"github.com/shirou/gopsutil/v4/process"
2019
"github.com/stretchr/testify/require"
2120

@@ -251,33 +250,41 @@ func countGoLines(tb testing.TB) int {
251250
func getLinterMemoryMB(tb testing.TB) (int, error) {
252251
tb.Helper()
253252

254-
processes, err := gops.Processes()
253+
processes, err := process.Processes()
255254
if err != nil {
256255
tb.Fatalf("can't get processes: %s", err)
257256
}
258257

259-
var progPID int
258+
var progPID int32
260259
for _, p := range processes {
260+
exe, err := p.Exe()
261+
if err != nil {
262+
continue
263+
}
261264
// The executable name can be shorter than the binary name.
262-
if strings.HasPrefix(binName, p.Executable()) {
263-
progPID = p.Pid()
265+
if strings.HasPrefix(binName, filepath.Base(exe)) {
266+
progPID = p.Pid
264267
break
265268
}
266269
}
267270
if progPID == 0 {
268271
return 0, errors.New("no process")
269272
}
270273

271-
allProgPIDs := []int{progPID}
274+
allProgPIDs := []int32{progPID}
272275
for _, p := range processes {
273-
if p.PPid() == progPID {
274-
allProgPIDs = append(allProgPIDs, p.Pid())
276+
ppid, err := p.Ppid()
277+
if err != nil {
278+
continue
279+
}
280+
if ppid == progPID {
281+
allProgPIDs = append(allProgPIDs, p.Pid)
275282
}
276283
}
277284

278285
var totalProgMemBytes uint64
279286
for _, pid := range allProgPIDs {
280-
p, err := process.NewProcess(int32(pid))
287+
p, err := process.NewProcess(pid)
281288
if err != nil {
282289
continue // subprocess could die
283290
}

0 commit comments

Comments
 (0)