feat(go): port process access detectors
This commit is contained in:
parent
f02509aab5
commit
fc9b5f0448
22 changed files with 554 additions and 40 deletions
24
go-agent/internal/detectors/fd.go
Normal file
24
go-agent/internal/detectors/fd.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package detectors
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func sortedFDs(targets map[string]string) []string {
|
||||
fds := make([]string, 0, len(targets))
|
||||
for fd := range targets {
|
||||
fds = append(fds, fd)
|
||||
}
|
||||
sort.Slice(fds, func(i, j int) bool {
|
||||
left, leftErr := strconv.Atoi(fds[i])
|
||||
right, rightErr := strconv.Atoi(fds[j])
|
||||
if leftErr == nil && rightErr == nil {
|
||||
return left < right
|
||||
}
|
||||
return fds[i] < fds[j]
|
||||
})
|
||||
return fds
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue