summaryrefslogtreecommitdiff
path: root/vendor/github.com/shirou/gopsutil/v4
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/shirou/gopsutil/v4')
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/cpu/cpu_aix_nocgo.go16
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.go15
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/cpu/cpu_dragonfly.go11
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd.go6
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/cpu/cpu_linux.go2
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/cpu/cpu_netbsd.go8
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/cpu/cpu_openbsd.go11
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/cpu/cpu_plan9.go7
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/cpu/cpu_solaris.go36
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/cpu/cpu_windows.go28
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/internal/common/binary.go8
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/internal/common/common.go11
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go11
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/internal/common/common_linux.go20
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/internal/common/common_testing.go14
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/internal/common/common_windows.go22
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.go6
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/mem/mem_fallback.go6
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/mem/mem_freebsd.go11
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/mem/mem_linux.go2
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/mem/mem_netbsd.go4
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/mem/mem_openbsd.go7
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/mem/mem_plan9.go3
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/mem/mem_solaris.go24
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/mem/mem_windows.go9
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/net/net.go6
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/net/net_aix.go25
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/net/net_aix_cgo.go4
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/net/net_aix_nocgo.go8
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/net/net_darwin.go22
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/net/net_fallback.go14
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/net/net_freebsd.go12
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/net/net_linux.go23
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/net/net_openbsd.go24
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/net/net_solaris.go17
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/net/net_unix.go6
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/net/net_windows.go50
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process.go29
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_bsd.go26
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go52
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go86
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go32
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_linux.go4
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go44
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go86
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_posix.go4
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go63
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_windows.go146
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_windows_32bit.go74
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_windows_64bit.go36
50 files changed, 624 insertions, 567 deletions
diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_aix_nocgo.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_aix_nocgo.go
index 329ef83..981e32e 100644
--- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_aix_nocgo.go
+++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_aix_nocgo.go
@@ -14,11 +14,11 @@ import (
func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
var ret []TimesStat
if percpu {
- per_out, err := invoke.CommandWithContext(ctx, "sar", "-u", "-P", "ALL", "10", "1")
+ perOut, err := invoke.CommandWithContext(ctx, "sar", "-u", "-P", "ALL", "10", "1")
if err != nil {
return nil, err
}
- lines := strings.Split(string(per_out), "\n")
+ lines := strings.Split(string(perOut), "\n")
if len(lines) < 6 {
return []TimesStat{}, common.ErrNotImplementedError
}
@@ -105,14 +105,15 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
ret := InfoStat{}
for _, line := range strings.Split(string(out), "\n") {
- if strings.HasPrefix(line, "Number Of Processors:") {
+ switch {
+ case strings.HasPrefix(line, "Number Of Processors:"):
p := strings.Fields(line)
if len(p) > 3 {
if t, err := strconv.ParseUint(p[3], 10, 64); err == nil {
ret.Cores = int32(t)
}
}
- } else if strings.HasPrefix(line, "Processor Clock Speed:") {
+ case strings.HasPrefix(line, "Processor Clock Speed:"):
p := strings.Fields(line)
if len(p) > 4 {
if t, err := strconv.ParseFloat(p[3], 64); err == nil {
@@ -128,13 +129,12 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
}
}
}
- break
- } else if strings.HasPrefix(line, "System Model:") {
+ case strings.HasPrefix(line, "System Model:"):
p := strings.Split(string(line), ":")
if p != nil {
ret.VendorID = strings.TrimSpace(p[1])
}
- } else if strings.HasPrefix(line, "Processor Type:") {
+ case strings.HasPrefix(line, "Processor Type:"):
p := strings.Split(string(line), ":")
if p != nil {
c := strings.Split(string(p[1]), "_")
@@ -148,7 +148,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
return []InfoStat{ret}, nil
}
-func CountsWithContext(ctx context.Context, logical bool) (int, error) {
+func CountsWithContext(ctx context.Context, _ bool) (int, error) {
info, err := InfoWithContext(ctx)
if err == nil {
return int(info[0].Cores), nil
diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.go
index b3e3a66..c61a470 100644
--- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.go
+++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_darwin.go
@@ -5,6 +5,7 @@ package cpu
import (
"context"
+ "errors"
"fmt"
"strconv"
"strings"
@@ -37,10 +38,10 @@ const (
// mach/processor_info.h
const (
- processorCpuLoadInfo = 2
+ processorCpuLoadInfo = 2 //nolint:revive //FIXME
)
-type hostCpuLoadInfoData struct {
+type hostCpuLoadInfoData struct { //nolint:revive //FIXME
cpuTicks [cpuStateMax]uint32
}
@@ -59,7 +60,7 @@ func Times(percpu bool) ([]TimesStat, error) {
return TimesWithContext(context.Background(), percpu)
}
-func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
+func TimesWithContext(_ context.Context, percpu bool) ([]TimesStat, error) {
lib, err := common.NewLibrary(common.System)
if err != nil {
return nil, err
@@ -78,7 +79,7 @@ func Info() ([]InfoStat, error) {
return InfoWithContext(context.Background())
}
-func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
+func InfoWithContext(_ context.Context) ([]InfoStat, error) {
var ret []InfoStat
c := InfoStat{}
@@ -121,7 +122,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
return append(ret, c), nil
}
-func CountsWithContext(ctx context.Context, logical bool) (int, error) {
+func CountsWithContext(_ context.Context, logical bool) (int, error) {
var cpuArgument string
if logical {
cpuArgument = "hw.logicalcpu"
@@ -152,6 +153,10 @@ func perCPUTimes(machLib *common.Library) ([]TimesStat, error) {
return nil, fmt.Errorf("host_processor_info error=%d", status)
}
+ if cpuload == nil {
+ return nil, errors.New("host_processor_info returned nil cpuload")
+ }
+
defer vmDeallocate(machTaskSelf(), uintptr(unsafe.Pointer(cpuload)), uintptr(ncpu))
ret := []TimesStat{}
diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_dragonfly.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_dragonfly.go
index 19b1e9d..8232c48 100644
--- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_dragonfly.go
+++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_dragonfly.go
@@ -11,9 +11,10 @@ import (
"strings"
"unsafe"
- "github.com/shirou/gopsutil/v4/internal/common"
"github.com/tklauser/go-sysconf"
"golang.org/x/sys/unix"
+
+ "github.com/shirou/gopsutil/v4/internal/common"
)
var (
@@ -50,7 +51,7 @@ func Times(percpu bool) ([]TimesStat, error) {
return TimesWithContext(context.Background(), percpu)
}
-func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
+func TimesWithContext(_ context.Context, percpu bool) ([]TimesStat, error) {
if percpu {
buf, err := unix.SysctlRaw("kern.cp_times")
if err != nil {
@@ -91,7 +92,7 @@ func Info() ([]InfoStat, error) {
return InfoWithContext(context.Background())
}
-func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
+func InfoWithContext(_ context.Context) ([]InfoStat, error) {
const dmesgBoot = "/var/run/dmesg.boot"
c, err := parseDmesgBoot(dmesgBoot)
@@ -135,7 +136,7 @@ func parseDmesgBoot(fileName string) (InfoStat, error) {
c.VendorID = matches[1]
t, err := strconv.ParseInt(matches[2], 10, 32)
if err != nil {
- return c, fmt.Errorf("unable to parse DragonflyBSD CPU stepping information from %q: %v", line, err)
+ return c, fmt.Errorf("unable to parse DragonflyBSD CPU stepping information from %q: %w", line, err)
}
c.Stepping = int32(t)
} else if matches := featuresMatch.FindStringSubmatch(line); matches != nil {
@@ -152,6 +153,6 @@ func parseDmesgBoot(fileName string) (InfoStat, error) {
return c, nil
}
-func CountsWithContext(ctx context.Context, logical bool) (int, error) {
+func CountsWithContext(_ context.Context, _ bool) (int, error) {
return runtime.NumCPU(), nil
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd.go
index 5d17c7e..107b574 100644
--- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_freebsd.go
@@ -52,7 +52,7 @@ func Times(percpu bool) ([]TimesStat, error) {
return TimesWithContext(context.Background(), percpu)
}
-func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
+func TimesWithContext(_ context.Context, percpu bool) ([]TimesStat, error) {
if percpu {
buf, err := unix.SysctlRaw("kern.cp_times")
if err != nil {
@@ -93,7 +93,7 @@ func Info() ([]InfoStat, error) {
return InfoWithContext(context.Background())
}
-func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
+func InfoWithContext(_ context.Context) ([]InfoStat, error) {
const dmesgBoot = "/var/run/dmesg.boot"
c, num, err := parseDmesgBoot(dmesgBoot)
@@ -165,6 +165,6 @@ func parseDmesgBoot(fileName string) (InfoStat, int, error) {
return c, cpuNum, nil
}
-func CountsWithContext(ctx context.Context, logical bool) (int, error) {
+func CountsWithContext(_ context.Context, _ bool) (int, error) {
return runtime.NumCPU(), nil
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_linux.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_linux.go
index 5f595e7..a3c60ff 100644
--- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_linux.go
+++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_linux.go
@@ -157,7 +157,7 @@ func finishCPUInfo(ctx context.Context, c *InfoStat) {
}
c.Mhz = value / 1000.0 // value is in kHz
if c.Mhz > 9999 {
- c.Mhz = c.Mhz / 1000.0 // value in Hz
+ c.Mhz /= 1000.0 // value in Hz
}
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_netbsd.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_netbsd.go
index 198be5e..cc76985 100644
--- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_netbsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_netbsd.go
@@ -36,7 +36,7 @@ func Times(percpu bool) ([]TimesStat, error) {
return TimesWithContext(context.Background(), percpu)
}
-func TimesWithContext(ctx context.Context, percpu bool) (ret []TimesStat, err error) {
+func TimesWithContext(_ context.Context, percpu bool) (ret []TimesStat, err error) {
if !percpu {
mib := []int32{ctlKern, kernCpTime}
buf, _, err := common.CallSyscall(mib)
@@ -57,7 +57,7 @@ func TimesWithContext(ctx context.Context, percpu bool) (ret []TimesStat, err er
ncpu, err := unix.SysctlUint32("hw.ncpu")
if err != nil {
- return
+ return //nolint:nakedret //FIXME
}
var i uint32
@@ -87,7 +87,7 @@ func Info() ([]InfoStat, error) {
return InfoWithContext(context.Background())
}
-func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
+func InfoWithContext(_ context.Context) ([]InfoStat, error) {
var ret []InfoStat
var err error
@@ -115,6 +115,6 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
return append(ret, c), nil
}
-func CountsWithContext(ctx context.Context, logical bool) (int, error) {
+func CountsWithContext(_ context.Context, _ bool) (int, error) {
return runtime.NumCPU(), nil
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_openbsd.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_openbsd.go
index 33233d3..9038a4d 100644
--- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_openbsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_openbsd.go
@@ -9,9 +9,10 @@ import (
"runtime"
"unsafe"
- "github.com/shirou/gopsutil/v4/internal/common"
"github.com/tklauser/go-sysconf"
"golang.org/x/sys/unix"
+
+ "github.com/shirou/gopsutil/v4/internal/common"
)
const (
@@ -53,7 +54,7 @@ func Times(percpu bool) ([]TimesStat, error) {
return TimesWithContext(context.Background(), percpu)
}
-func TimesWithContext(ctx context.Context, percpu bool) (ret []TimesStat, err error) {
+func TimesWithContext(_ context.Context, percpu bool) (ret []TimesStat, err error) {
if !percpu {
mib := []int32{ctlKern, kernCpTime}
buf, _, err := common.CallSyscall(mib)
@@ -74,7 +75,7 @@ func TimesWithContext(ctx context.Context, percpu bool) (ret []TimesStat, err er
ncpu, err := unix.SysctlUint32("hw.ncpu")
if err != nil {
- return
+ return //nolint:nakedret //FIXME
}
var i uint32
@@ -107,7 +108,7 @@ func Info() ([]InfoStat, error) {
return InfoWithContext(context.Background())
}
-func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
+func InfoWithContext(_ context.Context) ([]InfoStat, error) {
var ret []InfoStat
var err error
@@ -132,6 +133,6 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
return append(ret, c), nil
}
-func CountsWithContext(ctx context.Context, logical bool) (int, error) {
+func CountsWithContext(_ context.Context, _ bool) (int, error) {
return runtime.NumCPU(), nil
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_plan9.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_plan9.go
index bff2e0c..02ad3f7 100644
--- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_plan9.go
+++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_plan9.go
@@ -9,6 +9,7 @@ import (
"runtime"
stats "github.com/lufia/plan9stats"
+
"github.com/shirou/gopsutil/v4/internal/common"
)
@@ -16,7 +17,7 @@ func Times(percpu bool) ([]TimesStat, error) {
return TimesWithContext(context.Background(), percpu)
}
-func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
+func TimesWithContext(ctx context.Context, _ bool) ([]TimesStat, error) {
// BUG: percpu flag is not supported yet.
root := os.Getenv("HOST_ROOT")
c, err := stats.ReadCPUType(ctx, stats.WithRootDir(root))
@@ -41,10 +42,10 @@ func Info() ([]InfoStat, error) {
return InfoWithContext(context.Background())
}
-func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
+func InfoWithContext(_ context.Context) ([]InfoStat, error) {
return []InfoStat{}, common.ErrNotImplementedError
}
-func CountsWithContext(ctx context.Context, logical bool) (int, error) {
+func CountsWithContext(_ context.Context, _ bool) (int, error) {
return runtime.NumCPU(), nil
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_solaris.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_solaris.go
index d8ba1d3..1911c0f 100644
--- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_solaris.go
+++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_solaris.go
@@ -42,7 +42,7 @@ var kstatSplit = regexp.MustCompile(`[:\s]+`)
func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
kstatSysOut, err := invoke.CommandWithContext(ctx, "kstat", "-p", "cpu_stat:*:*:/^idle$|^user$|^kernel$|^iowait$|^swap$/")
if err != nil {
- return nil, fmt.Errorf("cannot execute kstat: %s", err)
+ return nil, fmt.Errorf("cannot execute kstat: %w", err)
}
cpu := make(map[float64]float64)
idle := make(map[float64]float64)
@@ -57,31 +57,31 @@ func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
}
cpuNumber, err := strconv.ParseFloat(fields[1], 64)
if err != nil {
- return nil, fmt.Errorf("cannot parse cpu number: %s", err)
+ return nil, fmt.Errorf("cannot parse cpu number: %w", err)
}
cpu[cpuNumber] = cpuNumber
switch fields[3] {
case "idle":
idle[cpuNumber], err = strconv.ParseFloat(fields[4], 64)
if err != nil {
- return nil, fmt.Errorf("cannot parse idle: %s", err)
+ return nil, fmt.Errorf("cannot parse idle: %w", err)
}
case "user":
user[cpuNumber], err = strconv.ParseFloat(fields[4], 64)
if err != nil {
- return nil, fmt.Errorf("cannot parse user: %s", err)
+ return nil, fmt.Errorf("cannot parse user: %w", err)
}
case "kernel":
kern[cpuNumber], err = strconv.ParseFloat(fields[4], 64)
if err != nil {
- return nil, fmt.Errorf("cannot parse kernel: %s", err)
+ return nil, fmt.Errorf("cannot parse kernel: %w", err)
}
case "iowait":
iowt[cpuNumber], err = strconv.ParseFloat(fields[4], 64)
if err != nil {
- return nil, fmt.Errorf("cannot parse iowait: %s", err)
+ return nil, fmt.Errorf("cannot parse iowait: %w", err)
}
- //not sure how this translates, don't report, add to kernel, something else?
+ // not sure how this translates, don't report, add to kernel, something else?
/*case "swap":
swap[cpuNumber], err = strconv.ParseFloat(fields[4], 64)
if err != nil {
@@ -121,22 +121,22 @@ func Info() ([]InfoStat, error) {
func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
psrInfoOut, err := invoke.CommandWithContext(ctx, "psrinfo", "-p", "-v")
if err != nil {
- return nil, fmt.Errorf("cannot execute psrinfo: %s", err)
+ return nil, fmt.Errorf("cannot execute psrinfo: %w", err)
}
procs, err := parseProcessorInfo(string(psrInfoOut))
if err != nil {
- return nil, fmt.Errorf("error parsing psrinfo output: %s", err)
+ return nil, fmt.Errorf("error parsing psrinfo output: %w", err)
}
isaInfoOut, err := invoke.CommandWithContext(ctx, "isainfo", "-b", "-v")
if err != nil {
- return nil, fmt.Errorf("cannot execute isainfo: %s", err)
+ return nil, fmt.Errorf("cannot execute isainfo: %w", err)
}
flags, err := parseISAInfo(string(isaInfoOut))
if err != nil {
- return nil, fmt.Errorf("error parsing isainfo output: %s", err)
+ return nil, fmt.Errorf("error parsing isainfo output: %w", err)
}
result := make([]InfoStat, 0, len(flags))
@@ -160,7 +160,7 @@ func parseISAInfo(cmdOutput string) ([]string, error) {
}
flags := make([]string, len(words)-4)
- for i, val := range words[4:] {
+ for i, val := range words[4:] { //nolint:gosimple //FIXME
flags[i] = val
}
sort.Strings(flags)
@@ -194,7 +194,7 @@ func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) {
if physicalCPU[psrStepOffset] != "" {
stepParsed, err := strconv.ParseInt(physicalCPU[psrStepOffset], 10, 32)
if err != nil {
- return nil, fmt.Errorf("cannot parse value %q for step as 32-bit integer: %s", physicalCPU[9], err)
+ return nil, fmt.Errorf("cannot parse value %q for step as 32-bit integer: %w", physicalCPU[9], err)
}
step = int32(stepParsed)
}
@@ -202,7 +202,7 @@ func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) {
if physicalCPU[psrClockOffset] != "" {
clockParsed, err := strconv.ParseInt(physicalCPU[psrClockOffset], 10, 64)
if err != nil {
- return nil, fmt.Errorf("cannot parse value %q for clock as 32-bit integer: %s", physicalCPU[10], err)
+ return nil, fmt.Errorf("cannot parse value %q for clock as 32-bit integer: %w", physicalCPU[10], err)
}
clock = float64(clockParsed)
}
@@ -214,7 +214,7 @@ func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) {
case physicalCPU[psrNumCoresOffset] != "":
numCores, err = strconv.ParseInt(physicalCPU[psrNumCoresOffset], 10, 32)
if err != nil {
- return nil, fmt.Errorf("cannot parse value %q for core count as 32-bit integer: %s", physicalCPU[1], err)
+ return nil, fmt.Errorf("cannot parse value %q for core count as 32-bit integer: %w", physicalCPU[1], err)
}
for i := 0; i < int(numCores); i++ {
@@ -235,12 +235,12 @@ func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) {
case physicalCPU[psrNumCoresHTOffset] != "":
numCores, err = strconv.ParseInt(physicalCPU[psrNumCoresHTOffset], 10, 32)
if err != nil {
- return nil, fmt.Errorf("cannot parse value %q for core count as 32-bit integer: %s", physicalCPU[3], err)
+ return nil, fmt.Errorf("cannot parse value %q for core count as 32-bit integer: %w", physicalCPU[3], err)
}
numHT, err = strconv.ParseInt(physicalCPU[psrNumHTOffset], 10, 32)
if err != nil {
- return nil, fmt.Errorf("cannot parse value %q for hyperthread count as 32-bit integer: %s", physicalCPU[4], err)
+ return nil, fmt.Errorf("cannot parse value %q for hyperthread count as 32-bit integer: %w", physicalCPU[4], err)
}
for i := 0; i < int(numCores); i++ {
@@ -265,6 +265,6 @@ func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) {
return result, nil
}
-func CountsWithContext(ctx context.Context, logical bool) (int, error) {
+func CountsWithContext(_ context.Context, _ bool) (int, error) {
return runtime.NumCPU(), nil
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_windows.go b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_windows.go
index 4476b91..de86c04 100644
--- a/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_windows.go
+++ b/vendor/github.com/shirou/gopsutil/v4/cpu/cpu_windows.go
@@ -6,16 +6,18 @@ package cpu
import (
"context"
"fmt"
+ "strconv"
"unsafe"
- "github.com/shirou/gopsutil/v4/internal/common"
"github.com/yusufpapurcu/wmi"
"golang.org/x/sys/windows"
+
+ "github.com/shirou/gopsutil/v4/internal/common"
)
var procGetNativeSystemInfo = common.Modkernel32.NewProc("GetNativeSystemInfo")
-type win32_Processor struct {
+type win32_Processor struct { //nolint:revive //FIXME
Family uint16
Manufacturer string
Name string
@@ -31,13 +33,13 @@ type win32_Processor struct {
// https://docs.microsoft.com/en-us/windows/desktop/api/winternl/nf-winternl-ntquerysysteminformation#system_processor_performance_information
// additional fields documented here
// https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/processor_performance.htm
-type win32_SystemProcessorPerformanceInformation struct {
- IdleTime int64 // idle time in 100ns (this is not a filetime).
- KernelTime int64 // kernel time in 100ns. kernel time includes idle time. (this is not a filetime).
- UserTime int64 // usertime in 100ns (this is not a filetime).
- DpcTime int64 // dpc time in 100ns (this is not a filetime).
- InterruptTime int64 // interrupt time in 100ns
- InterruptCount uint32
+type win32_SystemProcessorPerformanceInformation struct { //nolint:revive //FIXME
+ IdleTime int64 // idle time in 100ns (this is not a filetime).
+ KernelTime int64 // kernel time in 100ns. kernel time includes idle time. (this is not a filetime).
+ UserTime int64 // usertime in 100ns (this is not a filetime).
+ DpcTime int64 // dpc time in 100ns (this is not a filetime).
+ InterruptTime int64 // interrupt time in 100ns
+ InterruptCount uint64 // ULONG needs to be uint64
}
const (
@@ -45,10 +47,10 @@ const (
// systemProcessorPerformanceInformationClass information class to query with NTQuerySystemInformation
// https://processhacker.sourceforge.io/doc/ntexapi_8h.html#ad5d815b48e8f4da1ef2eb7a2f18a54e0
- win32_SystemProcessorPerformanceInformationClass = 8
+ win32_SystemProcessorPerformanceInformationClass = 8 //nolint:revive //FIXME
// size of systemProcessorPerformanceInfoSize in memory
- win32_SystemProcessorPerformanceInfoSize = uint32(unsafe.Sizeof(win32_SystemProcessorPerformanceInformation{}))
+ win32_SystemProcessorPerformanceInfoSize = uint32(unsafe.Sizeof(win32_SystemProcessorPerformanceInformation{})) //nolint:revive //FIXME
)
// Times returns times stat per cpu and combined for all CPUs
@@ -56,7 +58,7 @@ func Times(percpu bool) ([]TimesStat, error) {
return TimesWithContext(context.Background(), percpu)
}
-func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
+func TimesWithContext(_ context.Context, percpu bool) ([]TimesStat, error) {
if percpu {
return perCPUTimes()
}
@@ -110,7 +112,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
cpu := InfoStat{
CPU: int32(i),
- Family: fmt.Sprintf("%d", l.Family),
+ Family: strconv.FormatUint(uint64(l.Family), 10),
VendorID: l.Manufacturer,
ModelName: l.Name,
Cores: int32(l.NumberOfLogicalProcessors),
diff --git a/vendor/github.com/shirou/gopsutil/v4/internal/common/binary.go b/vendor/github.com/shirou/gopsutil/v4/internal/common/binary.go
index 6e75e74..11a4fd4 100644
--- a/vendor/github.com/shirou/gopsutil/v4/internal/common/binary.go
+++ b/vendor/github.com/shirou/gopsutil/v4/internal/common/binary.go
@@ -137,7 +137,7 @@ func (bigEndian) GoString() string { return "binary.BigEndian" }
// blank (_) field names is skipped; i.e., blank field names
// may be used for padding.
// When reading into a struct, all non-blank fields must be exported.
-func Read(r io.Reader, order ByteOrder, data interface{}) error {
+func Read(r io.Reader, order ByteOrder, data any) error {
// Fast path for basic types and slices.
if n := intDataSize(data); n != 0 {
var b [8]byte
@@ -229,7 +229,7 @@ func Read(r io.Reader, order ByteOrder, data interface{}) error {
// and read from successive fields of the data.
// When writing structs, zero values are written for fields
// with blank (_) field names.
-func Write(w io.Writer, order ByteOrder, data interface{}) error {
+func Write(w io.Writer, order ByteOrder, data any) error {
// Fast path for basic types and slices.
if n := intDataSize(data); n != 0 {
var b [8]byte
@@ -339,7 +339,7 @@ func Write(w io.Writer, order ByteOrder, data interface{}) error {
// Size returns how many bytes Write would generate to encode the value v, which
// must be a fixed-size value or a slice of fixed-size values, or a pointer to such data.
// If v is neither of these, Size returns -1.
-func Size(v interface{}) int {
+func Size(v any) int {
return dataSize(reflect.Indirect(reflect.ValueOf(v)))
}
@@ -607,7 +607,7 @@ func (e *encoder) skip(v reflect.Value) {
// intDataSize returns the size of the data required to represent the data when encoded.
// It returns zero if the type cannot be implemented by the fast path in Read or Write.
-func intDataSize(data interface{}) int {
+func intDataSize(data any) int {
switch data := data.(type) {
case int8, *int8, *uint8:
return 1
diff --git a/vendor/github.com/shirou/gopsutil/v4/internal/common/common.go b/vendor/github.com/shirou/gopsutil/v4/internal/common/common.go
index 868ea4d..4f9b2f7 100644
--- a/vendor/github.com/shirou/gopsutil/v4/internal/common/common.go
+++ b/vendor/github.com/shirou/gopsutil/v4/internal/common/common.go
@@ -31,8 +31,9 @@ import (
)
var (
- Timeout = 3 * time.Second
- ErrTimeout = errors.New("command timed out")
+ Timeout = 3 * time.Second
+ ErrNotImplementedError = errors.New("not implemented yet")
+ ErrTimeout = errors.New("command timed out")
)
type Invoker interface {
@@ -93,12 +94,10 @@ func (i FakeInvoke) Command(name string, arg ...string) ([]byte, error) {
return []byte{}, fmt.Errorf("could not find testdata: %s", fpath)
}
-func (i FakeInvoke) CommandWithContext(ctx context.Context, name string, arg ...string) ([]byte, error) {
+func (i FakeInvoke) CommandWithContext(_ context.Context, name string, arg ...string) ([]byte, error) {
return i.Command(name, arg...)
}
-var ErrNotImplementedError = errors.New("not implemented yet")
-
// ReadFile reads contents from a file
func ReadFile(filename string) (string, error) {
content, err := os.ReadFile(filename)
@@ -311,7 +310,7 @@ func IntContains(target []int, src int) bool {
// get struct attributes.
// This method is used only for debugging platform dependent code.
-func attributes(m interface{}) map[string]reflect.Type {
+func attributes(m any) map[string]reflect.Type {
typ := reflect.TypeOf(m)
if typ.Kind() == reflect.Ptr {
typ = typ.Elem()
diff --git a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go
index 2de3bb1..afa780d 100644
--- a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go
+++ b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go
@@ -5,6 +5,7 @@ package common
import (
"context"
+ "errors"
"fmt"
"os"
"os/exec"
@@ -306,7 +307,7 @@ const (
func NewSMC(ioKit *Library) (*SMC, error) {
if ioKit.path != IOKit {
- return nil, fmt.Errorf("library is not IOKit")
+ return nil, errors.New("library is not IOKit")
}
ioServiceGetMatchingService := GetFunc[IOServiceGetMatchingServiceFunc](ioKit, IOServiceGetMatchingServiceSym)
@@ -324,7 +325,7 @@ func NewSMC(ioKit *Library) (*SMC, error) {
var conn uint32
if result := ioServiceOpen(service, machTaskSelf(), 0, &conn); result != 0 {
- return nil, fmt.Errorf("ERROR: IOServiceOpen failed")
+ return nil, errors.New("ERROR: IOServiceOpen failed")
}
ioObjectRelease(service)
@@ -343,7 +344,7 @@ func (s *SMC) Close() error {
ioServiceClose := GetFunc[IOServiceCloseFunc](s.lib, IOServiceCloseSym)
if result := ioServiceClose(s.conn); result != 0 {
- return fmt.Errorf("ERROR: IOServiceClose failed")
+ return errors.New("ERROR: IOServiceClose failed")
}
return nil
}
@@ -367,8 +368,8 @@ func (s CStr) Ptr() *byte {
return &s[0]
}
-func (c CStr) Addr() uintptr {
- return uintptr(unsafe.Pointer(c.Ptr()))
+func (s CStr) Addr() uintptr {
+ return uintptr(unsafe.Pointer(s.Ptr()))
}
func (s CStr) GoString() string {
diff --git a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_linux.go b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_linux.go
index 277034f..04ec171 100644
--- a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_linux.go
+++ b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_linux.go
@@ -196,19 +196,20 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) {
if PathExists(filename) {
contents, err := ReadLines(filename)
if err == nil {
- if StringsContains(contents, "kvm") {
+ switch {
+ case StringsContains(contents, "kvm"):
system = "kvm"
role = "host"
- } else if StringsContains(contents, "hv_util") {
+ case StringsContains(contents, "hv_util"):
system = "hyperv"
role = "guest"
- } else if StringsContains(contents, "vboxdrv") {
+ case StringsContains(contents, "vboxdrv"):
system = "vbox"
role = "host"
- } else if StringsContains(contents, "vboxguest") {
+ case StringsContains(contents, "vboxguest"):
system = "vbox"
role = "guest"
- } else if StringsContains(contents, "vmware") {
+ case StringsContains(contents, "vmware"):
system = "vmware"
role = "guest"
}
@@ -273,16 +274,17 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) {
if PathExists(filepath.Join(filename, "self", "cgroup")) {
contents, err := ReadLines(filepath.Join(filename, "self", "cgroup"))
if err == nil {
- if StringsContains(contents, "lxc") {
+ switch {
+ case StringsContains(contents, "lxc"):
system = "lxc"
role = "guest"
- } else if StringsContains(contents, "docker") {
+ case StringsContains(contents, "docker"):
system = "docker"
role = "guest"
- } else if StringsContains(contents, "machine-rkt") {
+ case StringsContains(contents, "machine-rkt"):
system = "rkt"
role = "guest"
- } else if PathExists("/usr/bin/lxc-version") {
+ case PathExists("/usr/bin/lxc-version"):
system = "lxc"
role = "host"
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_testing.go b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_testing.go
new file mode 100644
index 0000000..55f36f1
--- /dev/null
+++ b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_testing.go
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: BSD-3-Clause
+package common
+
+import (
+ "errors"
+ "testing"
+)
+
+func SkipIfNotImplementedErr(tb testing.TB, err error) {
+ tb.Helper()
+ if errors.Is(err, ErrNotImplementedError) {
+ tb.Skip("not implemented")
+ }
+}
diff --git a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_windows.go b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_windows.go
index 766ed2f..f3ec5a9 100644
--- a/vendor/github.com/shirou/gopsutil/v4/internal/common/common_windows.go
+++ b/vendor/github.com/shirou/gopsutil/v4/internal/common/common_windows.go
@@ -17,19 +17,19 @@ import (
)
// for double values
-type PDH_FMT_COUNTERVALUE_DOUBLE struct {
+type PDH_FMT_COUNTERVALUE_DOUBLE struct { //nolint:revive //FIXME
CStatus uint32
DoubleValue float64
}
// for 64 bit integer values
-type PDH_FMT_COUNTERVALUE_LARGE struct {
+type PDH_FMT_COUNTERVALUE_LARGE struct { //nolint:revive //FIXME
CStatus uint32
LargeValue int64
}
// for long values
-type PDH_FMT_COUNTERVALUE_LONG struct {
+type PDH_FMT_COUNTERVALUE_LONG struct { //nolint:revive //FIXME
CStatus uint32
LongValue int32
padding [4]byte
@@ -197,7 +197,7 @@ func ProcessorQueueLengthCounter() (*Win32PerformanceCounter, error) {
}
// WMIQueryWithContext - wraps wmi.Query with a timed-out context to avoid hanging
-func WMIQueryWithContext(ctx context.Context, query string, dst interface{}, connectServerArgs ...interface{}) error {
+func WMIQueryWithContext(ctx context.Context, query string, dst any, connectServerArgs ...any) error {
if _, ok := ctx.Deadline(); !ok {
ctxTimeout, cancel := context.WithTimeout(ctx, Timeout)
defer cancel()
@@ -233,7 +233,7 @@ func ConvertDOSPath(p string) string {
ret, _, _ := procQueryDosDeviceW.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(szDeviceName))),
uintptr(unsafe.Pointer(&szTarget[0])),
uintptr(len(szTarget)))
- if ret != 0 && windows.UTF16ToString(szTarget[:]) == rawDrive {
+ if ret != 0 && windows.UTF16ToString(szTarget) == rawDrive {
return filepath.Join(szDeviceName, p[len(rawDrive):])
}
}
@@ -273,19 +273,19 @@ type SystemExtendedHandleInformation struct {
// CallWithExpandingBuffer https://github.com/hillu/go-ntdll
func CallWithExpandingBuffer(fn func() NtStatus, buf *[]byte, resultLength *uint32) NtStatus {
for {
- if st := fn(); st == STATUS_BUFFER_OVERFLOW || st == STATUS_BUFFER_TOO_SMALL || st == STATUS_INFO_LENGTH_MISMATCH {
+ st := fn()
+ if st == STATUS_BUFFER_OVERFLOW || st == STATUS_BUFFER_TOO_SMALL || st == STATUS_INFO_LENGTH_MISMATCH {
if int(*resultLength) <= cap(*buf) {
(*reflect.SliceHeader)(unsafe.Pointer(buf)).Len = int(*resultLength)
} else {
*buf = make([]byte, int(*resultLength))
}
continue
- } else {
- if !st.IsError() {
- *buf = (*buf)[:int(*resultLength)]
- }
- return st
}
+ if !st.IsError() {
+ *buf = (*buf)[:int(*resultLength)]
+ }
+ return st
}
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.go
index a4c15f6..7d96a3b 100644
--- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.go
+++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_darwin.go
@@ -35,7 +35,7 @@ func SwapMemory() (*SwapMemoryStat, error) {
return SwapMemoryWithContext(context.Background())
}
-func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
+func SwapMemoryWithContext(_ context.Context) (*SwapMemoryStat, error) {
// https://github.com/yanllearnn/go-osstat/blob/ae8a279d26f52ec946a03698c7f50a26cfb427e3/memory/memory_darwin.go
var ret *SwapMemoryStat
@@ -67,7 +67,7 @@ func SwapDevices() ([]*SwapDevice, error) {
return SwapDevicesWithContext(context.Background())
}
-func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) {
+func SwapDevicesWithContext(_ context.Context) ([]*SwapDevice, error) {
return nil, common.ErrNotImplementedError
}
@@ -84,7 +84,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
return VirtualMemoryWithContext(context.Background())
}
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
+func VirtualMemoryWithContext(_ context.Context) (*VirtualMemoryStat, error) {
machLib, err := common.NewLibrary(common.System)
if err != nil {
return nil, err
diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_fallback.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_fallback.go
index ba882c8..74283a2 100644
--- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_fallback.go
+++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_fallback.go
@@ -13,7 +13,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
return VirtualMemoryWithContext(context.Background())
}
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
+func VirtualMemoryWithContext(_ context.Context) (*VirtualMemoryStat, error) {
return nil, common.ErrNotImplementedError
}
@@ -21,7 +21,7 @@ func SwapMemory() (*SwapMemoryStat, error) {
return SwapMemoryWithContext(context.Background())
}
-func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
+func SwapMemoryWithContext(_ context.Context) (*SwapMemoryStat, error) {
return nil, common.ErrNotImplementedError
}
@@ -29,6 +29,6 @@ func SwapDevices() ([]*SwapDevice, error) {
return SwapDevicesWithContext(context.Background())
}
-func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) {
+func SwapDevicesWithContext(_ context.Context) ([]*SwapDevice, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_freebsd.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_freebsd.go
index a6dedde..dbe6d91 100644
--- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_freebsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_freebsd.go
@@ -17,7 +17,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
return VirtualMemoryWithContext(context.Background())
}
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
+func VirtualMemoryWithContext(_ context.Context) (*VirtualMemoryStat, error) {
pageSize, err := common.SysctlUint("vm.stats.vm.v_page_size")
if err != nil {
return nil, err
@@ -110,7 +110,7 @@ type xswdev11 struct {
Used int32 // Used is the number of blocks used
}
-func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
+func SwapMemoryWithContext(_ context.Context) (*SwapMemoryStat, error) {
// FreeBSD can have multiple swap devices so we total them up
i, err := common.SysctlUint("vm.nswapdev")
if err != nil {
@@ -139,7 +139,8 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
// first, try to parse with version 2
xsw := (*xswdev)(unsafe.Pointer(&buf[0]))
- if xsw.Version == XSWDEV_VERSION11 {
+ switch {
+ case xsw.Version == XSWDEV_VERSION11:
// this is version 1, so try to parse again
xsw := (*xswdev11)(unsafe.Pointer(&buf[0]))
if xsw.Version != XSWDEV_VERSION11 {
@@ -147,9 +148,9 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
}
s.Total += uint64(xsw.NBlks)
s.Used += uint64(xsw.Used)
- } else if xsw.Version != XSWDEV_VERSION {
+ case xsw.Version != XSWDEV_VERSION:
return nil, errors.New("xswdev version mismatch")
- } else {
+ default:
s.Total += uint64(xsw.NBlks)
s.Used += uint64(xsw.Used)
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_linux.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_linux.go
index 05bfdaf..3e6e4e3 100644
--- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_linux.go
+++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_linux.go
@@ -50,7 +50,7 @@ func fillFromMeminfoWithContext(ctx context.Context) (*VirtualMemoryStat, *ExVir
}
key := strings.TrimSpace(fields[0])
value := strings.TrimSpace(fields[1])
- value = strings.Replace(value, " kB", "", -1)
+ value = strings.ReplaceAll(value, " kB", "")
switch key {
case "MemTotal":
diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_netbsd.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_netbsd.go
index 0a41b3e..8ef539c 100644
--- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_netbsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_netbsd.go
@@ -15,7 +15,7 @@ func GetPageSize() (uint64, error) {
return GetPageSizeWithContext(context.Background())
}
-func GetPageSizeWithContext(ctx context.Context) (uint64, error) {
+func GetPageSizeWithContext(_ context.Context) (uint64, error) {
uvmexp, err := unix.SysctlUvmexp("vm.uvmexp2")
if err != nil {
return 0, err
@@ -27,7 +27,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
return VirtualMemoryWithContext(context.Background())
}
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
+func VirtualMemoryWithContext(_ context.Context) (*VirtualMemoryStat, error) {
uvmexp, err := unix.SysctlUvmexp("vm.uvmexp2")
if err != nil {
return nil, err
diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_openbsd.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_openbsd.go
index 2510bb0..680cad1 100644
--- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_openbsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_openbsd.go
@@ -10,15 +10,16 @@ import (
"errors"
"fmt"
- "github.com/shirou/gopsutil/v4/internal/common"
"golang.org/x/sys/unix"
+
+ "github.com/shirou/gopsutil/v4/internal/common"
)
func GetPageSize() (uint64, error) {
return GetPageSizeWithContext(context.Background())
}
-func GetPageSizeWithContext(ctx context.Context) (uint64, error) {
+func GetPageSizeWithContext(_ context.Context) (uint64, error) {
uvmexp, err := unix.SysctlUvmexp("vm.uvmexp")
if err != nil {
return 0, err
@@ -30,7 +31,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
return VirtualMemoryWithContext(context.Background())
}
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
+func VirtualMemoryWithContext(_ context.Context) (*VirtualMemoryStat, error) {
uvmexp, err := unix.SysctlUvmexp("vm.uvmexp")
if err != nil {
return nil, err
diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_plan9.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_plan9.go
index c17a102..0df0745 100644
--- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_plan9.go
+++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_plan9.go
@@ -8,6 +8,7 @@ import (
"os"
stats "github.com/lufia/plan9stats"
+
"github.com/shirou/gopsutil/v4/internal/common"
)
@@ -63,6 +64,6 @@ func SwapDevices() ([]*SwapDevice, error) {
return SwapDevicesWithContext(context.Background())
}
-func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) {
+func SwapDevicesWithContext(_ context.Context) ([]*SwapDevice, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_solaris.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_solaris.go
index 06d0d9a..1a391dc 100644
--- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_solaris.go
+++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_solaris.go
@@ -11,8 +11,9 @@ import (
"strconv"
"strings"
- "github.com/shirou/gopsutil/v4/internal/common"
"github.com/tklauser/go-sysconf"
+
+ "github.com/shirou/gopsutil/v4/internal/common"
)
// VirtualMemory for Solaris is a minimal implementation which only returns
@@ -24,17 +25,17 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
result := &VirtualMemoryStat{}
- zoneName, err := zoneName()
+ zoneName, err := zoneName(ctx)
if err != nil {
return nil, err
}
if zoneName == "global" {
- cap, err := globalZoneMemoryCapacity()
+ capacity, err := globalZoneMemoryCapacity(ctx)
if err != nil {
return nil, err
}
- result.Total = cap
+ result.Total = capacity
freemem, err := globalZoneFreeMemory(ctx)
if err != nil {
return nil, err
@@ -43,11 +44,11 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
result.Free = freemem
result.Used = result.Total - result.Free
} else {
- cap, err := nonGlobalZoneMemoryCapacity()
+ capacity, err := nonGlobalZoneMemoryCapacity(ctx)
if err != nil {
return nil, err
}
- result.Total = cap
+ result.Total = capacity
}
return result, nil
@@ -57,12 +58,11 @@ func SwapMemory() (*SwapMemoryStat, error) {
return SwapMemoryWithContext(context.Background())
}
-func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
+func SwapMemoryWithContext(_ context.Context) (*SwapMemoryStat, error) {
return nil, common.ErrNotImplementedError
}
-func zoneName() (string, error) {
- ctx := context.Background()
+func zoneName(ctx context.Context) (string, error) {
out, err := invoke.CommandWithContext(ctx, "zonename")
if err != nil {
return "", err
@@ -73,8 +73,7 @@ func zoneName() (string, error) {
var globalZoneMemoryCapacityMatch = regexp.MustCompile(`[Mm]emory size: (\d+) Megabytes`)
-func globalZoneMemoryCapacity() (uint64, error) {
- ctx := context.Background()
+func globalZoneMemoryCapacity(ctx context.Context) (uint64, error) {
out, err := invoke.CommandWithContext(ctx, "prtconf")
if err != nil {
return 0, err
@@ -114,8 +113,7 @@ func globalZoneFreeMemory(ctx context.Context) (uint64, error) {
var kstatMatch = regexp.MustCompile(`(\S+)\s+(\S*)`)
-func nonGlobalZoneMemoryCapacity() (uint64, error) {
- ctx := context.Background()
+func nonGlobalZoneMemoryCapacity(ctx context.Context) (uint64, error) {
out, err := invoke.CommandWithContext(ctx, "kstat", "-p", "-c", "zone_memory_cap", "memory_cap:*:*:physcap")
if err != nil {
return 0, err
diff --git a/vendor/github.com/shirou/gopsutil/v4/mem/mem_windows.go b/vendor/github.com/shirou/gopsutil/v4/mem/mem_windows.go
index a94b61f..015c1a1 100644
--- a/vendor/github.com/shirou/gopsutil/v4/mem/mem_windows.go
+++ b/vendor/github.com/shirou/gopsutil/v4/mem/mem_windows.go
@@ -9,8 +9,9 @@ import (
"syscall"
"unsafe"
- "github.com/shirou/gopsutil/v4/internal/common"
"golang.org/x/sys/windows"
+
+ "github.com/shirou/gopsutil/v4/internal/common"
)
var (
@@ -36,7 +37,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
return VirtualMemoryWithContext(context.Background())
}
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
+func VirtualMemoryWithContext(_ context.Context) (*VirtualMemoryStat, error) {
var memInfo memoryStatusEx
memInfo.cbSize = uint32(unsafe.Sizeof(memInfo))
mem, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo)))
@@ -76,7 +77,7 @@ func SwapMemory() (*SwapMemoryStat, error) {
return SwapMemoryWithContext(context.Background())
}
-func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
+func SwapMemoryWithContext(_ context.Context) (*SwapMemoryStat, error) {
// Use the performance counter to get the swap usage percentage
counter, err := common.NewWin32PerformanceCounter("swap_percentage", `\Paging File(_Total)\% Usage`)
if err != nil {
@@ -150,7 +151,7 @@ func SwapDevices() ([]*SwapDevice, error) {
return SwapDevicesWithContext(context.Background())
}
-func SwapDevicesWithContext(ctx context.Context) ([]*SwapDevice, error) {
+func SwapDevicesWithContext(_ context.Context) ([]*SwapDevice, error) {
pageSizeOnce.Do(func() {
var sysInfo systemInfo
procGetNativeSystemInfo.Call(uintptr(unsafe.Pointer(&sysInfo)))
diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net.go b/vendor/github.com/shirou/gopsutil/v4/net/net.go
index 74af54a..78798c5 100644
--- a/vendor/github.com/shirou/gopsutil/v4/net/net.go
+++ b/vendor/github.com/shirou/gopsutil/v4/net/net.go
@@ -207,7 +207,7 @@ func Interfaces() (InterfaceStatList, error) {
return InterfacesWithContext(context.Background())
}
-func InterfacesWithContext(ctx context.Context) (InterfaceStatList, error) {
+func InterfacesWithContext(_ context.Context) (InterfaceStatList, error) {
is, err := net.Interfaces()
if err != nil {
return nil, err
@@ -255,7 +255,7 @@ func InterfacesWithContext(ctx context.Context) (InterfaceStatList, error) {
return ret, nil
}
-func getIOCountersAll(n []IOCountersStat) ([]IOCountersStat, error) {
+func getIOCountersAll(n []IOCountersStat) []IOCountersStat {
r := IOCountersStat{
Name: "all",
}
@@ -270,7 +270,7 @@ func getIOCountersAll(n []IOCountersStat) ([]IOCountersStat, error) {
r.Dropout += nic.Dropout
}
- return []IOCountersStat{r}, nil
+ return []IOCountersStat{r}
}
// NetIOCounters returns network I/O statistics for every network
diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_aix.go b/vendor/github.com/shirou/gopsutil/v4/net/net_aix.go
index 9df01e3..a5fa881 100644
--- a/vendor/github.com/shirou/gopsutil/v4/net/net_aix.go
+++ b/vendor/github.com/shirou/gopsutil/v4/net/net_aix.go
@@ -15,23 +15,23 @@ import (
)
// Deprecated: use process.PidsWithContext instead
-func PidsWithContext(ctx context.Context) ([]int32, error) {
+func PidsWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
- return IOCounters(pernic)
+func IOCountersByFileWithContext(ctx context.Context, pernic bool, _ string) ([]IOCountersStat, error) {
+ return IOCountersWithContext(ctx, pernic)
}
-func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
+func FilterCountersWithContext(_ context.Context) ([]FilterStat, error) {
return nil, common.ErrNotImplementedError
}
-func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackStat, error) {
+func ConntrackStatsWithContext(_ context.Context, _ bool) ([]ConntrackStat, error) {
return nil, common.ErrNotImplementedError
}
-func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
+func ProtoCountersWithContext(_ context.Context, _ []string) ([]ProtoCountersStat, error) {
return nil, common.ErrNotImplementedError
}
@@ -193,7 +193,8 @@ func parseNetstatA(output string, kind string) ([]ConnectionStat, error) {
continue
}
- if strings.HasPrefix(fields[0], "f1") {
+ switch {
+ case strings.HasPrefix(fields[0], "f1"):
// Unix lines
if len(fields) < 2 {
// every unix connections have two lines
@@ -202,12 +203,12 @@ func parseNetstatA(output string, kind string) ([]ConnectionStat, error) {
c, err := parseNetstatUnixLine(fields)
if err != nil {
- return nil, fmt.Errorf("failed to parse Unix Address (%s): %s", line, err)
+ return nil, fmt.Errorf("failed to parse Unix Address (%s): %w", line, err)
}
ret = append(ret, c)
- } else if strings.HasPrefix(fields[0], "tcp") || strings.HasPrefix(fields[0], "udp") {
+ case strings.HasPrefix(fields[0], "tcp") || strings.HasPrefix(fields[0], "udp"):
// Inet lines
if !hasCorrectInetProto(kind, fields[0]) {
continue
@@ -221,11 +222,11 @@ func parseNetstatA(output string, kind string) ([]ConnectionStat, error) {
c, err := parseNetstatNetLine(line)
if err != nil {
- return nil, fmt.Errorf("failed to parse Inet Address (%s): %s", line, err)
+ return nil, fmt.Errorf("failed to parse Inet Address (%s): %w", line, err)
}
ret = append(ret, c)
- } else {
+ default:
// Header lines
continue
}
@@ -294,6 +295,6 @@ func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, p
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn, true)
}
-func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int, skipUids bool) ([]ConnectionStat, error) {
+func connectionsPidMaxWithoutUidsWithContext(_ context.Context, _ string, _ int32, _ int, _ bool) ([]ConnectionStat, error) {
return []ConnectionStat{}, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_aix_cgo.go b/vendor/github.com/shirou/gopsutil/v4/net/net_aix_cgo.go
index a45a5b7..f7da4ce 100644
--- a/vendor/github.com/shirou/gopsutil/v4/net/net_aix_cgo.go
+++ b/vendor/github.com/shirou/gopsutil/v4/net/net_aix_cgo.go
@@ -29,8 +29,8 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
}
iocounters = append(iocounters, n)
}
- if pernic == false {
- return getIOCountersAll(iocounters)
+ if !pernic {
+ return getIOCountersAll(iocounters), nil
}
return iocounters, nil
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_aix_nocgo.go b/vendor/github.com/shirou/gopsutil/v4/net/net_aix_nocgo.go
index f63a21e..834534d 100644
--- a/vendor/github.com/shirou/gopsutil/v4/net/net_aix_nocgo.go
+++ b/vendor/github.com/shirou/gopsutil/v4/net/net_aix_nocgo.go
@@ -5,7 +5,7 @@ package net
import (
"context"
- "fmt"
+ "errors"
"strconv"
"strings"
@@ -19,7 +19,7 @@ func parseNetstatI(output string) ([]IOCountersStat, error) {
// Check first line is header
if len(lines) > 0 && strings.Fields(lines[0])[0] != "Name" {
- return nil, fmt.Errorf("not a 'netstat -i' output")
+ return nil, errors.New("not a 'netstat -i' output")
}
for _, line := range lines[1:] {
@@ -88,8 +88,8 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
if err != nil {
return nil, err
}
- if pernic == false {
- return getIOCountersAll(iocounters)
+ if !pernic {
+ return getIOCountersAll(iocounters), nil
}
return iocounters, nil
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_darwin.go b/vendor/github.com/shirou/gopsutil/v4/net/net_darwin.go
index 86c541e..5814a54 100644
--- a/vendor/github.com/shirou/gopsutil/v4/net/net_darwin.go
+++ b/vendor/github.com/shirou/gopsutil/v4/net/net_darwin.go
@@ -30,14 +30,14 @@ func parseNetstatLine(line string) (stat *IOCountersStat, linkID *uint, err erro
if columns[0] == "Name" {
err = errNetstatHeader
- return
+ return //nolint:nakedret //FIXME
}
// try to extract the numeric value from <Link#123>
if subMatch := netstatLinkRegexp.FindStringSubmatch(columns[2]); len(subMatch) == 2 {
numericValue, err = strconv.ParseUint(subMatch[1], 10, 64)
if err != nil {
- return
+ return //nolint:nakedret //FIXME
}
linkIDUint := uint(numericValue)
linkID = &linkIDUint
@@ -51,7 +51,7 @@ func parseNetstatLine(line string) (stat *IOCountersStat, linkID *uint, err erro
}
if numberColumns < 11 || numberColumns > 13 {
err = fmt.Errorf("Line %q do have an invalid number of columns %d", line, numberColumns)
- return
+ return //nolint:nakedret //FIXME
}
parsed := make([]uint64, 0, 7)
@@ -74,7 +74,7 @@ func parseNetstatLine(line string) (stat *IOCountersStat, linkID *uint, err erro
}
if numericValue, err = strconv.ParseUint(target, 10, 64); err != nil {
- return
+ return //nolint:nakedret //FIXME
}
parsed = append(parsed, numericValue)
}
@@ -91,7 +91,7 @@ func parseNetstatLine(line string) (stat *IOCountersStat, linkID *uint, err erro
if len(parsed) == 7 {
stat.Dropout = parsed[6]
}
- return
+ return //nolint:nakedret //FIXME
}
type netstatInterface struct {
@@ -163,7 +163,7 @@ func (mapi mapInterfaceNameUsage) notTruncated() []string {
}
// Deprecated: use process.PidsWithContext instead
-func PidsWithContext(ctx context.Context) ([]int32, error) {
+func PidsWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
@@ -249,23 +249,23 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
}
if !pernic {
- return getIOCountersAll(ret)
+ return getIOCountersAll(ret), nil
}
return ret, nil
}
-func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
+func IOCountersByFileWithContext(ctx context.Context, pernic bool, _ string) ([]IOCountersStat, error) {
return IOCountersWithContext(ctx, pernic)
}
-func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
+func FilterCountersWithContext(_ context.Context) ([]FilterStat, error) {
return nil, common.ErrNotImplementedError
}
-func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackStat, error) {
+func ConntrackStatsWithContext(_ context.Context, _ bool) ([]ConntrackStat, error) {
return nil, common.ErrNotImplementedError
}
-func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
+func ProtoCountersWithContext(_ context.Context, _ []string) ([]ProtoCountersStat, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_fallback.go b/vendor/github.com/shirou/gopsutil/v4/net/net_fallback.go
index 7d7596a..29c2a14 100644
--- a/vendor/github.com/shirou/gopsutil/v4/net/net_fallback.go
+++ b/vendor/github.com/shirou/gopsutil/v4/net/net_fallback.go
@@ -9,32 +9,32 @@ import (
"github.com/shirou/gopsutil/v4/internal/common"
)
-func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) {
+func IOCountersWithContext(_ context.Context, _ bool) ([]IOCountersStat, error) {
return []IOCountersStat{}, common.ErrNotImplementedError
}
-func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
+func IOCountersByFileWithContext(ctx context.Context, pernic bool, _ string) ([]IOCountersStat, error) {
return IOCountersWithContext(ctx, pernic)
}
-func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
+func FilterCountersWithContext(_ context.Context) ([]FilterStat, error) {
return nil, common.ErrNotImplementedError
}
-func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackStat, error) {
+func ConntrackStatsWithContext(_ context.Context, _ bool) ([]ConntrackStat, error) {
return nil, common.ErrNotImplementedError
}
-func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
+func ProtoCountersWithContext(_ context.Context, _ []string) ([]ProtoCountersStat, error) {
return nil, common.ErrNotImplementedError
}
// Deprecated: use process.PidsWithContext instead
-func PidsWithContext(ctx context.Context) ([]int32, error) {
+func PidsWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, error) {
+func ConnectionsWithContext(_ context.Context, _ string) ([]ConnectionStat, error) {
return []ConnectionStat{}, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_freebsd.go b/vendor/github.com/shirou/gopsutil/v4/net/net_freebsd.go
index 655e133..a72aa00 100644
--- a/vendor/github.com/shirou/gopsutil/v4/net/net_freebsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/net/net_freebsd.go
@@ -12,7 +12,7 @@ import (
)
// Deprecated: use process.PidsWithContext instead
-func PidsWithContext(ctx context.Context) ([]int32, error) {
+func PidsWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
@@ -85,24 +85,24 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
}
if !pernic {
- return getIOCountersAll(ret)
+ return getIOCountersAll(ret), nil
}
return ret, nil
}
-func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
+func IOCountersByFileWithContext(ctx context.Context, pernic bool, _ string) ([]IOCountersStat, error) {
return IOCountersWithContext(ctx, pernic)
}
-func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
+func FilterCountersWithContext(_ context.Context) ([]FilterStat, error) {
return nil, common.ErrNotImplementedError
}
-func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackStat, error) {
+func ConntrackStatsWithContext(_ context.Context, _ bool) ([]ConntrackStat, error) {
return nil, common.ErrNotImplementedError
}
-func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
+func ProtoCountersWithContext(_ context.Context, _ []string) ([]ProtoCountersStat, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_linux.go b/vendor/github.com/shirou/gopsutil/v4/net/net_linux.go
index 23113fe..9697526 100644
--- a/vendor/github.com/shirou/gopsutil/v4/net/net_linux.go
+++ b/vendor/github.com/shirou/gopsutil/v4/net/net_linux.go
@@ -27,16 +27,16 @@ const ( // Conntrack Column numbers
ctINVALID
ctIGNORE
ctDELETE
- ctDELETE_LIST
+ ctDELETE_LIST //nolint:revive //FIXME
ctINSERT
- ctINSERT_FAILED
+ ctINSERT_FAILED //nolint:revive //FIXME
ctDROP
- ctEARLY_DROP
- ctICMP_ERROR
- CT_EXPEctNEW
- ctEXPECT_CREATE
- CT_EXPEctDELETE
- ctSEARCH_RESTART
+ ctEARLY_DROP //nolint:revive //FIXME
+ ctICMP_ERROR //nolint:revive //FIXME
+ CT_EXPEctNEW //nolint:revive //FIXME
+ ctEXPECT_CREATE //nolint:revive //FIXME
+ CT_EXPEctDELETE //nolint:revive //FIXME
+ ctSEARCH_RESTART //nolint:revive //FIXME
)
func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) {
@@ -44,7 +44,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
return IOCountersByFileWithContext(ctx, pernic, filename)
}
-func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
+func IOCountersByFileWithContext(_ context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
lines, err := common.ReadLines(filename)
if err != nil {
return nil, err
@@ -128,7 +128,7 @@ func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename stri
}
if !pernic {
- return getIOCountersAll(ret)
+ return getIOCountersAll(ret), nil
}
return ret, nil
@@ -571,8 +571,7 @@ func (p *process) fillFromStatus(ctx context.Context) error {
continue
}
value := tabParts[1]
- switch strings.TrimRight(tabParts[0], ":") {
- case "Uid":
+ if strings.TrimRight(tabParts[0], ":") == "Uid" {
p.uids = make([]int32, 0, 4)
for _, i := range strings.Split(value, "\t") {
v, err := strconv.ParseInt(i, 10, 32)
diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_openbsd.go b/vendor/github.com/shirou/gopsutil/v4/net/net_openbsd.go
index a90d590..41f0f46 100644
--- a/vendor/github.com/shirou/gopsutil/v4/net/net_openbsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/net/net_openbsd.go
@@ -107,7 +107,7 @@ func ParseNetstat(output string, mode string,
}
// Deprecated: use process.PidsWithContext instead
-func PidsWithContext(ctx context.Context) ([]int32, error) {
+func PidsWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
@@ -150,26 +150,26 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
ret = append(ret, ioc)
}
- if pernic == false {
- return getIOCountersAll(ret)
+ if !pernic {
+ return getIOCountersAll(ret), nil
}
return ret, nil
}
-func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
- return IOCounters(pernic)
+func IOCountersByFileWithContext(ctx context.Context, pernic bool, _ string) ([]IOCountersStat, error) {
+ return IOCountersWithContext(ctx, pernic)
}
-func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
+func FilterCountersWithContext(_ context.Context) ([]FilterStat, error) {
return nil, common.ErrNotImplementedError
}
-func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackStat, error) {
+func ConntrackStatsWithContext(_ context.Context, _ bool) ([]ConntrackStat, error) {
return nil, common.ErrNotImplementedError
}
-func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
+func ProtoCountersWithContext(_ context.Context, _ []string) ([]ProtoCountersStat, error) {
return nil, common.ErrNotImplementedError
}
@@ -310,15 +310,15 @@ func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat,
return ret, nil
}
-func ConnectionsPidWithContext(ctx context.Context, kind string, pid int32) ([]ConnectionStat, error) {
+func ConnectionsPidWithContext(_ context.Context, _ string, _ int32) ([]ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func ConnectionsMaxWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) {
+func ConnectionsMaxWithContext(_ context.Context, _ string, _ int) ([]ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func ConnectionsPidMaxWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
+func ConnectionsPidMaxWithContext(_ context.Context, _ string, _ int32, _ int) ([]ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
@@ -338,6 +338,6 @@ func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, p
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn)
}
-func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
+func connectionsPidMaxWithoutUidsWithContext(_ context.Context, _ string, _ int32, _ int) ([]ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_solaris.go b/vendor/github.com/shirou/gopsutil/v4/net/net_solaris.go
index 83eb1d0..df06780 100644
--- a/vendor/github.com/shirou/gopsutil/v4/net/net_solaris.go
+++ b/vendor/github.com/shirou/gopsutil/v4/net/net_solaris.go
@@ -5,6 +5,7 @@ package net
import (
"context"
+ "errors"
"fmt"
"regexp"
"runtime"
@@ -29,7 +30,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
lines := strings.Split(strings.TrimSpace(string(kstatSysOut)), "\n")
if len(lines) == 0 {
- return nil, fmt.Errorf("no interface found")
+ return nil, errors.New("no interface found")
}
rbytes64arr := make(map[string]uint64)
ipackets64arr := make(map[string]uint64)
@@ -104,34 +105,34 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
}
if !pernic {
- return getIOCountersAll(ret)
+ return getIOCountersAll(ret), nil
}
return ret, nil
}
-func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
+func IOCountersByFileWithContext(ctx context.Context, pernic bool, _ string) ([]IOCountersStat, error) {
return IOCountersWithContext(ctx, pernic)
}
-func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
+func FilterCountersWithContext(_ context.Context) ([]FilterStat, error) {
return nil, common.ErrNotImplementedError
}
-func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackStat, error) {
+func ConntrackStatsWithContext(_ context.Context, _ bool) ([]ConntrackStat, error) {
return nil, common.ErrNotImplementedError
}
-func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
+func ProtoCountersWithContext(_ context.Context, _ []string) ([]ProtoCountersStat, error) {
return nil, common.ErrNotImplementedError
}
// Deprecated: use process.PidsWithContext instead
-func PidsWithContext(ctx context.Context) ([]int32, error) {
+func PidsWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, error) {
+func ConnectionsWithContext(_ context.Context, _ string) ([]ConnectionStat, error) {
return []ConnectionStat{}, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_unix.go b/vendor/github.com/shirou/gopsutil/v4/net/net_unix.go
index 6eb7e2f..ae7e9d8 100644
--- a/vendor/github.com/shirou/gopsutil/v4/net/net_unix.go
+++ b/vendor/github.com/shirou/gopsutil/v4/net/net_unix.go
@@ -18,7 +18,7 @@ func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat,
return ConnectionsPidWithContext(ctx, kind, 0)
}
-func ConnectionsMaxWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) {
+func ConnectionsMaxWithContext(_ context.Context, _ string, _ int) ([]ConnectionStat, error) {
return []ConnectionStat{}, common.ErrNotImplementedError
}
@@ -163,7 +163,7 @@ func parseNetAddr(line string) (laddr Addr, raddr Addr, err error) {
return laddr, raddr, err
}
-func ConnectionsPidMaxWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
+func ConnectionsPidMaxWithContext(_ context.Context, _ string, _ int32, _ int) ([]ConnectionStat, error) {
return []ConnectionStat{}, common.ErrNotImplementedError
}
@@ -183,6 +183,6 @@ func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, p
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn)
}
-func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
+func connectionsPidMaxWithoutUidsWithContext(_ context.Context, _ string, _ int32, _ int) ([]ConnectionStat, error) {
return []ConnectionStat{}, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/net/net_windows.go b/vendor/github.com/shirou/gopsutil/v4/net/net_windows.go
index 00ebf89..9622896 100644
--- a/vendor/github.com/shirou/gopsutil/v4/net/net_windows.go
+++ b/vendor/github.com/shirou/gopsutil/v4/net/net_windows.go
@@ -5,14 +5,16 @@ package net
import (
"context"
+ "errors"
"fmt"
"net"
"os"
"syscall"
"unsafe"
- "github.com/shirou/gopsutil/v4/internal/common"
"golang.org/x/sys/windows"
+
+ "github.com/shirou/gopsutil/v4/internal/common"
)
var (
@@ -94,7 +96,7 @@ const (
type mibIfRow2 struct {
InterfaceLuid uint64
InterfaceIndex uint32
- InterfaceGuid guid
+ InterfaceGuid guid //nolint:revive //FIXME
Alias [maxStringSize + 1]uint16
Description [maxStringSize + 1]uint16
PhysicalAddressLength uint32
@@ -111,7 +113,7 @@ type mibIfRow2 struct {
OperStatus uint32
AdminStatus uint32
MediaConnectState uint32
- NetworkGuid guid
+ NetworkGuid guid //nolint:revive //FIXME
ConnectionType uint32
padding1 [pad0for64_4for32]byte
TransmitLinkSpeed uint64
@@ -136,7 +138,7 @@ type mibIfRow2 struct {
OutQLen uint64
}
-func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) {
+func IOCountersWithContext(_ context.Context, pernic bool) ([]IOCountersStat, error) {
ifs, err := net.Interfaces()
if err != nil {
return nil, err
@@ -191,20 +193,20 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
}
if !pernic {
- return getIOCountersAll(counters)
+ return getIOCountersAll(counters), nil
}
return counters, nil
}
-func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
- return IOCounters(pernic)
+func IOCountersByFileWithContext(ctx context.Context, pernic bool, _ string) ([]IOCountersStat, error) {
+ return IOCountersWithContext(ctx, pernic)
}
func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, error) {
return ConnectionsPidWithContext(ctx, kind, 0)
}
-func ConnectionsPidWithContext(ctx context.Context, kind string, pid int32) ([]ConnectionStat, error) {
+func ConnectionsPidWithContext(_ context.Context, kind string, pid int32) ([]ConnectionStat, error) {
tmap, ok := netConnectionKindMap[kind]
if !ok {
return nil, fmt.Errorf("invalid kind, %s", kind)
@@ -238,7 +240,7 @@ func getProcInet(kinds []netConnectionKindType, pid int32) ([]ConnectionStat, er
func getNetStatWithKind(kindType netConnectionKindType) ([]ConnectionStat, error) {
if kindType.filename == "" {
- return nil, fmt.Errorf("kind filename must be required")
+ return nil, errors.New("kind filename must be required")
}
switch kindType.filename {
@@ -256,7 +258,7 @@ func getNetStatWithKind(kindType netConnectionKindType) ([]ConnectionStat, error
}
// Deprecated: use process.PidsWithContext instead
-func PidsWithContext(ctx context.Context) ([]int32, error) {
+func PidsWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
@@ -288,15 +290,15 @@ func connectionsPidMaxWithoutUidsWithContext(_ context.Context, _ string, _ int3
return []ConnectionStat{}, common.ErrNotImplementedError
}
-func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
+func FilterCountersWithContext(_ context.Context) ([]FilterStat, error) {
return nil, common.ErrNotImplementedError
}
-func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackStat, error) {
+func ConntrackStatsWithContext(_ context.Context, _ bool) ([]ConntrackStat, error) {
return nil, common.ErrNotImplementedError
}
-func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
+func ProtoCountersWithContext(_ context.Context, _ []string) ([]ProtoCountersStat, error) {
return nil, common.ErrNotImplementedError
}
@@ -326,7 +328,7 @@ func getTableUintptr(family uint32, buf []byte) uintptr {
return p
}
-func getTableInfo(filename string, table interface{}) (index, step, length int) {
+func getTableInfo(filename string, table any) (index, step, length int) {
switch filename {
case kindTCP4.filename:
index = int(unsafe.Sizeof(table.(pmibTCPTableOwnerPidAll).DwNumEntries))
@@ -360,7 +362,7 @@ func getTCPConnections(family uint32) ([]ConnectionStat, error) {
)
if family == 0 {
- return nil, fmt.Errorf("faimly must be required")
+ return nil, errors.New("faimly must be required")
}
for {
@@ -381,7 +383,7 @@ func getTCPConnections(family uint32) ([]ConnectionStat, error) {
}
}
- err := getExtendedTcpTable(p,
+ err := getExtendedTCPTable(p,
&size,
true,
family,
@@ -390,7 +392,7 @@ func getTCPConnections(family uint32) ([]ConnectionStat, error) {
if err == nil {
break
}
- if err != windows.ERROR_INSUFFICIENT_BUFFER {
+ if !errors.Is(err, windows.ERROR_INSUFFICIENT_BUFFER) {
return nil, err
}
buf = make([]byte, size)
@@ -441,7 +443,7 @@ func getUDPConnections(family uint32) ([]ConnectionStat, error) {
)
if family == 0 {
- return nil, fmt.Errorf("faimly must be required")
+ return nil, errors.New("faimly must be required")
}
for {
@@ -462,7 +464,7 @@ func getUDPConnections(family uint32) ([]ConnectionStat, error) {
}
}
- err := getExtendedUdpTable(
+ err := getExtendedUDPTable(
p,
&size,
true,
@@ -473,7 +475,7 @@ func getUDPConnections(family uint32) ([]ConnectionStat, error) {
if err == nil {
break
}
- if err != windows.ERROR_INSUFFICIENT_BUFFER {
+ if !errors.Is(err, windows.ERROR_INSUFFICIENT_BUFFER) {
return nil, err
}
buf = make([]byte, size)
@@ -526,16 +528,16 @@ var tcpStatuses = map[mibTCPState]string{
12: "DELETE",
}
-func getExtendedTcpTable(pTcpTable uintptr, pdwSize *uint32, bOrder bool, ulAf uint32, tableClass tcpTableClass, reserved uint32) (errcode error) {
- r1, _, _ := syscall.Syscall6(procGetExtendedTCPTable.Addr(), 6, pTcpTable, uintptr(unsafe.Pointer(pdwSize)), getUintptrFromBool(bOrder), uintptr(ulAf), uintptr(tableClass), uintptr(reserved))
+func getExtendedTCPTable(pTCPTable uintptr, pdwSize *uint32, bOrder bool, ulAf uint32, tableClass tcpTableClass, reserved uint32) (errcode error) {
+ r1, _, _ := syscall.Syscall6(procGetExtendedTCPTable.Addr(), 6, pTCPTable, uintptr(unsafe.Pointer(pdwSize)), getUintptrFromBool(bOrder), uintptr(ulAf), uintptr(tableClass), uintptr(reserved))
if r1 != 0 {
errcode = syscall.Errno(r1)
}
return
}
-func getExtendedUdpTable(pUdpTable uintptr, pdwSize *uint32, bOrder bool, ulAf uint32, tableClass udpTableClass, reserved uint32) (errcode error) {
- r1, _, _ := syscall.Syscall6(procGetExtendedUDPTable.Addr(), 6, pUdpTable, uintptr(unsafe.Pointer(pdwSize)), getUintptrFromBool(bOrder), uintptr(ulAf), uintptr(tableClass), uintptr(reserved))
+func getExtendedUDPTable(pUDPTable uintptr, pdwSize *uint32, bOrder bool, ulAf uint32, tableClass udpTableClass, reserved uint32) (errcode error) {
+ r1, _, _ := syscall.Syscall6(procGetExtendedUDPTable.Addr(), 6, pUDPTable, uintptr(unsafe.Pointer(pdwSize)), getUintptrFromBool(bOrder), uintptr(ulAf), uintptr(tableClass), uintptr(reserved))
if r1 != 0 {
errcode = syscall.Errno(r1)
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process.go b/vendor/github.com/shirou/gopsutil/v4/process/process.go
index 70411c6..0bd4d9e 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process.go
@@ -269,13 +269,11 @@ func (p *Process) PercentWithContext(ctx context.Context, interval time.Duration
if err != nil {
return 0, err
}
- } else {
- if p.lastCPUTimes == nil {
- // invoked first time
- p.lastCPUTimes = cpuTimes
- p.lastCPUTime = now
- return 0, nil
- }
+ } else if p.lastCPUTimes == nil {
+ // invoked first time
+ p.lastCPUTimes = cpuTimes
+ p.lastCPUTime = now
+ return 0, nil
}
numcpu := runtime.NumCPU()
@@ -326,12 +324,12 @@ func calculatePercent(t1, t2 *cpu.TimesStat, delta float64, numcpu int) float64
return 0
}
// https://github.com/giampaolo/psutil/blob/c034e6692cf736b5e87d14418a8153bb03f6cf42/psutil/__init__.py#L1064
- delta_proc := (t2.User - t1.User) + (t2.System - t1.System)
- if delta_proc <= 0 {
+ deltaProc := (t2.User - t1.User) + (t2.System - t1.System)
+ if deltaProc <= 0 {
return 0
}
- overall_percent := ((delta_proc / delta) * 100) * float64(numcpu)
- return overall_percent
+ overallPercent := ((deltaProc / delta) * 100) * float64(numcpu)
+ return overallPercent
}
// MemoryPercent returns how many percent of the total RAM this process uses
@@ -361,7 +359,7 @@ func (p *Process) CPUPercent() (float64, error) {
}
func (p *Process) CPUPercentWithContext(ctx context.Context) (float64, error) {
- crt_time, err := p.createTimeWithContext(ctx)
+ createTime, err := p.createTimeWithContext(ctx)
if err != nil {
return 0, err
}
@@ -371,7 +369,7 @@ func (p *Process) CPUPercentWithContext(ctx context.Context) (float64, error) {
return 0, err
}
- created := time.Unix(0, crt_time*int64(time.Millisecond))
+ created := time.Unix(0, createTime*int64(time.Millisecond))
totalTime := time.Since(created).Seconds()
if totalTime <= 0 {
return 0, nil
@@ -408,6 +406,11 @@ func (p *Process) Cmdline() (string, error) {
// CmdlineSlice returns the command line arguments of the process as a slice with each
// element being an argument.
+//
+// On Windows, this assumes the command line is encoded according to the convention accepted by
+// [golang.org/x/sys/windows.CmdlineToArgv] (the most common convention). If this is not suitable,
+// you should instead use [Process.Cmdline] and parse the command line according to your specific
+// requirements.
func (p *Process) CmdlineSlice() ([]string, error) {
return p.CmdlineSliceWithContext(context.Background())
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_bsd.go b/vendor/github.com/shirou/gopsutil/v4/process/process_bsd.go
index dcc0561..1a58c3e 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_bsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_bsd.go
@@ -16,55 +16,55 @@ type MemoryInfoExStat struct{}
type MemoryMapsStat struct{}
-func (p *Process) TgidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) TgidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) IOniceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
+func (p *Process) RlimitWithContext(_ context.Context) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
+func (p *Process) RlimitUsageWithContext(_ context.Context, _ bool) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
+func (p *Process) NumCtxSwitchesWithContext(_ context.Context) (*NumCtxSwitchesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumFDsWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
+func (p *Process) CPUAffinityWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
+func (p *Process) MemoryInfoExWithContext(_ context.Context) (*MemoryInfoExStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error) {
+func (p *Process) PageFaultsWithContext(_ context.Context) (*PageFaultsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
+func (p *Process) OpenFilesWithContext(_ context.Context) ([]OpenFilesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
+func (p *Process) MemoryMapsWithContext(_ context.Context, _ bool) (*[]MemoryMapsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
+func (p *Process) ThreadsWithContext(_ context.Context) (map[int32]*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) EnvironWithContext(_ context.Context) ([]string, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go
index 33abc10..5afafd8 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go
@@ -7,6 +7,7 @@ import (
"bytes"
"context"
"encoding/binary"
+ "errors"
"fmt"
"path/filepath"
"runtime"
@@ -32,11 +33,11 @@ const (
KernProcPathname = 12 // path to executable
)
-type _Ctype_struct___0 struct {
+type _Ctype_struct___0 struct { //nolint:revive //FIXME
Pad uint64
}
-func pidsWithContext(ctx context.Context) ([]int32, error) {
+func pidsWithContext(_ context.Context) ([]int32, error) {
var ret []int32
kprocs, err := unix.SysctlKinfoProcSlice("kern.proc.all")
@@ -51,7 +52,7 @@ func pidsWithContext(ctx context.Context) ([]int32, error) {
return ret, nil
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -84,7 +85,7 @@ func (p *Process) NameWithContext(ctx context.Context) (string, error) {
return name, nil
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -112,7 +113,7 @@ func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
return strings.IndexByte(string(out), '+') != -1, nil
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -124,7 +125,7 @@ func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
return []uint32{userEffectiveUID}, nil
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -136,7 +137,7 @@ func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
return gids, nil
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
// k, err := p.getKProc()
// if err != nil {
@@ -151,7 +152,7 @@ func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
// return groups, nil
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
/*
k, err := p.getKProc()
@@ -169,7 +170,7 @@ func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
*/
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -177,7 +178,7 @@ func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
return int32(k.Proc.P_nice), nil
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
return nil, common.ErrNotImplementedError
}
@@ -239,11 +240,12 @@ func (p *Process) getKProc() (*unix.KinfoProc, error) {
// If passed arg pid is 0, get information from all process.
func callPsWithContext(ctx context.Context, arg string, pid int32, threadOption bool, nameOption bool) ([][]string, error) {
var cmd []string
- if pid == 0 { // will get from all processes.
+ switch {
+ case pid == 0: // will get from all processes.
cmd = []string{"-ax", "-o", arg}
- } else if threadOption {
+ case threadOption:
cmd = []string{"-x", "-o", arg, "-M", "-p", strconv.Itoa(int(pid))}
- } else {
+ default:
cmd = []string{"-x", "-o", arg, "-p", strconv.Itoa(int(pid))}
}
if nameOption {
@@ -303,7 +305,7 @@ func getTimeScaleToNanoSeconds() float64 {
return float64(timeBaseInfo.Numer) / float64(timeBaseInfo.Denom)
}
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
+func (p *Process) ExeWithContext(_ context.Context) (string, error) {
lib, err := registerFuncs()
if err != nil {
return "", err
@@ -332,7 +334,7 @@ type vnodePathInfo struct {
// EUID can access. Otherwise "operation not permitted" will be returned as the
// error.
// Note: This might also work for other *BSD OSs.
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
+func (p *Process) CwdWithContext(_ context.Context) (string, error) {
lib, err := registerFuncs()
if err != nil {
return "", err
@@ -348,7 +350,7 @@ func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
ret := procPidInfo(p.Pid, common.PROC_PIDVNODEPATHINFO, 0, uintptr(unsafe.Pointer(&vpi)), vpiSize)
errno, _ := lib.Dlsym("errno")
err = *(**unix.Errno)(unsafe.Pointer(&errno))
- if err == unix.EPERM {
+ if errors.Is(err, unix.EPERM) {
return "", ErrorNotPermitted
}
@@ -373,11 +375,11 @@ func procArgs(pid int32) ([]byte, int, error) {
return procargs, int(binary.LittleEndian.Uint32(nargs)), nil
}
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
- return p.cmdlineSliceWithContext(ctx, true)
+func (p *Process) CmdlineSliceWithContext(_ context.Context) ([]string, error) {
+ return p.cmdlineSlice()
}
-func (p *Process) cmdlineSliceWithContext(ctx context.Context, fallback bool) ([]string, error) {
+func (p *Process) cmdlineSlice() ([]string, error) {
pargs, nargs, err := procArgs(p.Pid)
if err != nil {
return nil, err
@@ -393,7 +395,7 @@ func (p *Process) cmdlineSliceWithContext(ctx context.Context, fallback bool) ([
// are the arguments. Everything else in the slice is then the environment
// of the process.
for _, arg := range args[1:] {
- argStr = string(arg[:])
+ argStr = string(arg)
if len(argStr) > 0 {
if nargs > 0 {
argSlice = append(argSlice, argStr)
@@ -408,8 +410,8 @@ func (p *Process) cmdlineSliceWithContext(ctx context.Context, fallback bool) ([
}
// cmdNameWithContext returns the command name (including spaces) without any arguments
-func (p *Process) cmdNameWithContext(ctx context.Context) (string, error) {
- r, err := p.cmdlineSliceWithContext(ctx, false)
+func (p *Process) cmdNameWithContext(_ context.Context) (string, error) {
+ r, err := p.cmdlineSlice()
if err != nil {
return "", err
}
@@ -429,7 +431,7 @@ func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
return strings.Join(r, " "), err
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
lib, err := registerFuncs()
if err != nil {
return 0, err
@@ -442,7 +444,7 @@ func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
return int32(ti.Threadnum), nil
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
lib, err := registerFuncs()
if err != nil {
return nil, err
@@ -461,7 +463,7 @@ func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error)
return ret, nil
}
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
+func (p *Process) MemoryInfoWithContext(_ context.Context) (*MemoryInfoStat, error) {
lib, err := registerFuncs()
if err != nil {
return nil, err
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go b/vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go
index e5410ea..b014297 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go
@@ -30,174 +30,174 @@ type MemoryMapsStat struct {
type MemoryInfoExStat struct{}
-func pidsWithContext(ctx context.Context) ([]int32, error) {
+func pidsWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
+func ProcessesWithContext(_ context.Context) ([]*Process, error) {
return nil, common.ErrNotImplementedError
}
-func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
+func PidExistsWithContext(_ context.Context, _ int32) (bool, error) {
return false, common.ErrNotImplementedError
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) NameWithContext(ctx context.Context) (string, error) {
+func (p *Process) NameWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) TgidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) TgidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
+func (p *Process) ExeWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
+func (p *Process) CmdlineWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) CmdlineSliceWithContext(_ context.Context) ([]string, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
+func (p *Process) CwdWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) StatusWithContext(_ context.Context) ([]string, error) {
return []string{""}, common.ErrNotImplementedError
}
-func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
+func (p *Process) ForegroundWithContext(_ context.Context) (bool, error) {
return false, common.ErrNotImplementedError
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) IOniceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
+func (p *Process) RlimitWithContext(_ context.Context) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
+func (p *Process) RlimitUsageWithContext(_ context.Context, _ bool) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
+func (p *Process) NumCtxSwitchesWithContext(_ context.Context) (*NumCtxSwitchesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumFDsWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
+func (p *Process) ThreadsWithContext(_ context.Context) (map[int32]*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
+func (p *Process) CPUAffinityWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
+func (p *Process) MemoryInfoWithContext(_ context.Context) (*MemoryInfoStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
+func (p *Process) MemoryInfoExWithContext(_ context.Context) (*MemoryInfoExStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error) {
+func (p *Process) PageFaultsWithContext(_ context.Context) (*PageFaultsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
+func (p *Process) ChildrenWithContext(_ context.Context) ([]*Process, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
+func (p *Process) OpenFilesWithContext(_ context.Context) ([]OpenFilesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsWithContext(_ context.Context) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsMaxWithContext(_ context.Context, _ int) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
+func (p *Process) MemoryMapsWithContext(_ context.Context, _ bool) (*[]MemoryMapsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) SendSignalWithContext(ctx context.Context, sig Signal) error {
+func (p *Process) SendSignalWithContext(_ context.Context, _ Signal) error {
return common.ErrNotImplementedError
}
-func (p *Process) SuspendWithContext(ctx context.Context) error {
+func (p *Process) SuspendWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) ResumeWithContext(ctx context.Context) error {
+func (p *Process) ResumeWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) TerminateWithContext(ctx context.Context) error {
+func (p *Process) TerminateWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) KillWithContext(ctx context.Context) error {
+func (p *Process) KillWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) UsernameWithContext(ctx context.Context) (string, error) {
+func (p *Process) UsernameWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) EnvironWithContext(_ context.Context) ([]string, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go b/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go
index a67ac0e..6df3142 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go
@@ -34,7 +34,7 @@ func pidsWithContext(ctx context.Context) ([]int32, error) {
return ret, nil
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -66,7 +66,7 @@ func (p *Process) NameWithContext(ctx context.Context) (string, error) {
return name, nil
}
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
+func (p *Process) CwdWithContext(_ context.Context) (string, error) {
mib := []int32{CTLKern, KernProc, KernProcCwd, p.Pid}
buf, length, err := common.CallSyscall(mib)
if err != nil {
@@ -87,7 +87,7 @@ func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
return cwd, nil
}
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
+func (p *Process) ExeWithContext(_ context.Context) (string, error) {
mib := []int32{CTLKern, KernProc, KernProcPathname, p.Pid}
buf, _, err := common.CallSyscall(mib)
if err != nil {
@@ -97,7 +97,7 @@ func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
return strings.Trim(string(buf), "\x00"), nil
}
-func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
+func (p *Process) CmdlineWithContext(_ context.Context) (string, error) {
mib := []int32{CTLKern, KernProc, KernProcArgs, p.Pid}
buf, _, err := common.CallSyscall(mib)
if err != nil {
@@ -110,7 +110,7 @@ func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
return strings.Join(ret, " "), nil
}
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) CmdlineSliceWithContext(_ context.Context) ([]string, error) {
mib := []int32{CTLKern, KernProc, KernProcArgs, p.Pid}
buf, _, err := common.CallSyscall(mib)
if err != nil {
@@ -131,7 +131,7 @@ func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error)
return strParts, nil
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -139,7 +139,7 @@ func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
return int64(k.Start.Sec)*1000 + int64(k.Start.Usec)/1000, nil
}
-func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) StatusWithContext(_ context.Context) ([]string, error) {
k, err := p.getKProc()
if err != nil {
return []string{""}, err
@@ -175,7 +175,7 @@ func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
return strings.IndexByte(string(out), '+') != -1, nil
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -188,7 +188,7 @@ func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
return uids, nil
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -200,7 +200,7 @@ func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
return gids, nil
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -214,7 +214,7 @@ func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
return groups, nil
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
k, err := p.getKProc()
if err != nil {
return "", err
@@ -230,7 +230,7 @@ func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
return termmap[ttyNr], nil
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -238,7 +238,7 @@ func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
return int32(k.Nice), nil
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -249,7 +249,7 @@ func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, e
}, nil
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -258,7 +258,7 @@ func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
return k.Numthreads, nil
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -270,7 +270,7 @@ func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error)
}, nil
}
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
+func (p *Process) MemoryInfoWithContext(_ context.Context) (*MemoryInfoStat, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go b/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go
index 68a8c88..bf96fd3 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go
@@ -194,7 +194,7 @@ func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
return nice, nil
}
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) IOniceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
@@ -310,7 +310,7 @@ func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error)
return cpuTimes, nil
}
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
+func (p *Process) CPUAffinityWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go
index 5e8a9e0..5a6d361 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go
@@ -8,7 +8,6 @@ import (
"context"
"encoding/binary"
"errors"
- "fmt"
"io"
"path/filepath"
"sort"
@@ -16,11 +15,12 @@ import (
"strings"
"unsafe"
- cpu "github.com/shirou/gopsutil/v4/cpu"
- "github.com/shirou/gopsutil/v4/internal/common"
- mem "github.com/shirou/gopsutil/v4/mem"
- net "github.com/shirou/gopsutil/v4/net"
"golang.org/x/sys/unix"
+
+ "github.com/shirou/gopsutil/v4/cpu"
+ "github.com/shirou/gopsutil/v4/internal/common"
+ "github.com/shirou/gopsutil/v4/mem"
+ "github.com/shirou/gopsutil/v4/net"
)
func pidsWithContext(ctx context.Context) ([]int32, error) {
@@ -37,7 +37,7 @@ func pidsWithContext(ctx context.Context) ([]int32, error) {
return ret, nil
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -69,7 +69,7 @@ func (p *Process) NameWithContext(ctx context.Context) (string, error) {
return name, nil
}
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
+func (p *Process) CwdWithContext(_ context.Context) (string, error) {
mib := []int32{CTLKern, KernProcCwd, p.Pid}
buf, _, err := common.CallSyscall(mib)
if err != nil {
@@ -78,11 +78,11 @@ func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
return common.ByteToString(buf), nil
}
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
+func (p *Process) ExeWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) CmdlineSliceWithContext(_ context.Context) ([]string, error) {
mib := []int32{CTLKern, KernProcArgs, p.Pid, KernProcArgv}
buf, _, err := common.CallSyscall(mib)
if err != nil {
@@ -130,7 +130,7 @@ func readPtr(r io.Reader) (uintptr, error) {
}
return uintptr(p), nil
default:
- return 0, fmt.Errorf("unsupported pointer size")
+ return 0, errors.New("unsupported pointer size")
}
}
@@ -142,11 +142,11 @@ func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
return strings.Join(argv, " "), nil
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) StatusWithContext(_ context.Context) ([]string, error) {
k, err := p.getKProc()
if err != nil {
return []string{""}, err
@@ -178,7 +178,7 @@ func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
return strings.IndexByte(string(out), '+') != -1, nil
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -191,7 +191,7 @@ func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
return uids, nil
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -203,7 +203,7 @@ func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
return gids, nil
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -217,7 +217,7 @@ func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
return groups, nil
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
k, err := p.getKProc()
if err != nil {
return "", err
@@ -233,7 +233,7 @@ func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
return termmap[ttyNr], nil
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -241,7 +241,7 @@ func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
return int32(k.Nice), nil
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -252,12 +252,12 @@ func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, e
}, nil
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
/* not supported, just return 1 */
return 1, nil
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -305,11 +305,11 @@ func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
return ret, nil
}
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsWithContext(_ context.Context) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsMaxWithContext(_ context.Context, _ int) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go b/vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go
index c82e54a..7f68771 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go
@@ -30,174 +30,174 @@ type MemoryMapsStat struct {
type MemoryInfoExStat struct{}
-func pidsWithContext(ctx context.Context) ([]int32, error) {
+func pidsWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
+func ProcessesWithContext(_ context.Context) ([]*Process, error) {
return nil, common.ErrNotImplementedError
}
-func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
+func PidExistsWithContext(_ context.Context, _ int32) (bool, error) {
return false, common.ErrNotImplementedError
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) NameWithContext(ctx context.Context) (string, error) {
+func (p *Process) NameWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) TgidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) TgidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
+func (p *Process) ExeWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
+func (p *Process) CmdlineWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) CmdlineSliceWithContext(_ context.Context) ([]string, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
+func (p *Process) CwdWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) StatusWithContext(_ context.Context) ([]string, error) {
return []string{""}, common.ErrNotImplementedError
}
-func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
+func (p *Process) ForegroundWithContext(_ context.Context) (bool, error) {
return false, common.ErrNotImplementedError
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) IOniceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
+func (p *Process) RlimitWithContext(_ context.Context) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
+func (p *Process) RlimitUsageWithContext(_ context.Context, _ bool) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
+func (p *Process) NumCtxSwitchesWithContext(_ context.Context) (*NumCtxSwitchesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumFDsWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
+func (p *Process) ThreadsWithContext(_ context.Context) (map[int32]*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
+func (p *Process) CPUAffinityWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
+func (p *Process) MemoryInfoWithContext(_ context.Context) (*MemoryInfoStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
+func (p *Process) MemoryInfoExWithContext(_ context.Context) (*MemoryInfoExStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error) {
+func (p *Process) PageFaultsWithContext(_ context.Context) (*PageFaultsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
+func (p *Process) ChildrenWithContext(_ context.Context) ([]*Process, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
+func (p *Process) OpenFilesWithContext(_ context.Context) ([]OpenFilesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsWithContext(_ context.Context) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsMaxWithContext(_ context.Context, _ int) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
+func (p *Process) MemoryMapsWithContext(_ context.Context, _ bool) (*[]MemoryMapsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) SendSignalWithContext(ctx context.Context, sig Signal) error {
+func (p *Process) SendSignalWithContext(_ context.Context, _ Signal) error {
return common.ErrNotImplementedError
}
-func (p *Process) SuspendWithContext(ctx context.Context) error {
+func (p *Process) SuspendWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) ResumeWithContext(ctx context.Context) error {
+func (p *Process) ResumeWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) TerminateWithContext(ctx context.Context) error {
+func (p *Process) TerminateWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) KillWithContext(ctx context.Context) error {
+func (p *Process) KillWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) UsernameWithContext(ctx context.Context) (string, error) {
+func (p *Process) UsernameWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) EnvironWithContext(_ context.Context) ([]string, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_posix.go b/vendor/github.com/shirou/gopsutil/v4/process/process_posix.go
index 96c5e06..12d5fe2 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_posix.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_posix.go
@@ -71,7 +71,7 @@ func getTerminalMap() (map[uint64]string, error) {
return nil, err
}
rdev := uint64(stat.Rdev)
- ret[rdev] = strings.Replace(name, "/dev", "", -1)
+ ret[rdev] = strings.ReplaceAll(name, "/dev", "")
}
return ret, nil
}
@@ -140,7 +140,7 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
return false, err
}
-func (p *Process) SendSignalWithContext(ctx context.Context, sig syscall.Signal) error {
+func (p *Process) SendSignalWithContext(_ context.Context, sig syscall.Signal) error {
process, err := os.FindProcess(int(p.Pid))
if err != nil {
return err
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go b/vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go
index 5c8d4d3..6af5633 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go
@@ -52,15 +52,15 @@ func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
return out, nil
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) NameWithContext(ctx context.Context) (string, error) {
+func (p *Process) NameWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) TgidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) TgidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
@@ -80,7 +80,7 @@ func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error)
return p.fillSliceFromCmdlineWithContext(ctx)
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
return 0, common.ErrNotImplementedError
}
@@ -88,51 +88,51 @@ func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
return p.fillFromPathCwdWithContext(ctx)
}
-func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) StatusWithContext(_ context.Context) ([]string, error) {
return []string{""}, common.ErrNotImplementedError
}
-func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
+func (p *Process) ForegroundWithContext(_ context.Context) (bool, error) {
return false, common.ErrNotImplementedError
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) IOniceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
+func (p *Process) RlimitWithContext(_ context.Context) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
+func (p *Process) RlimitUsageWithContext(_ context.Context, _ bool) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
+func (p *Process) NumCtxSwitchesWithContext(_ context.Context) (*NumCtxSwitchesStat, error) {
return nil, common.ErrNotImplementedError
}
@@ -141,55 +141,55 @@ func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
return int32(len(fnames)), err
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
+func (p *Process) ThreadsWithContext(_ context.Context) (map[int32]*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
+func (p *Process) CPUAffinityWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
+func (p *Process) MemoryInfoWithContext(_ context.Context) (*MemoryInfoStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
+func (p *Process) MemoryInfoExWithContext(_ context.Context) (*MemoryInfoExStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error) {
+func (p *Process) PageFaultsWithContext(_ context.Context) (*PageFaultsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
+func (p *Process) ChildrenWithContext(_ context.Context) ([]*Process, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
+func (p *Process) OpenFilesWithContext(_ context.Context) ([]OpenFilesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsWithContext(_ context.Context) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsMaxWithContext(_ context.Context, _ int) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
+func (p *Process) MemoryMapsWithContext(_ context.Context, _ bool) (*[]MemoryMapsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) EnvironWithContext(_ context.Context) ([]string, error) {
return nil, common.ErrNotImplementedError
}
@@ -247,10 +247,7 @@ func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error
return "", err
}
ret := strings.FieldsFunc(string(cmdline), func(r rune) bool {
- if r == '\u0000' {
- return true
- }
- return false
+ return r == '\u0000'
})
return strings.Join(ret, " "), nil
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go b/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go
index 012886d..c6069a5 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go
@@ -12,16 +12,16 @@ import (
"os"
"path/filepath"
"reflect"
- "strings"
"syscall"
"time"
"unicode/utf16"
"unsafe"
+ "golang.org/x/sys/windows"
+
"github.com/shirou/gopsutil/v4/cpu"
"github.com/shirou/gopsutil/v4/internal/common"
"github.com/shirou/gopsutil/v4/net"
- "golang.org/x/sys/windows"
)
type Signal = syscall.Signal
@@ -241,11 +241,11 @@ func init() {
0)
}
-func pidsWithContext(ctx context.Context) ([]int32, error) {
+func pidsWithContext(_ context.Context) ([]int32, error) {
// inspired by https://gist.github.com/henkman/3083408
// and https://github.com/giampaolo/psutil/blob/1c3a15f637521ba5c0031283da39c733fda53e4c/psutil/arch/windows/process_info.c#L315-L329
var ret []int32
- var read uint32 = 0
+ var read uint32
var psSize uint32 = 1024
const dwordSize uint32 = 4
@@ -288,10 +288,10 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
return false, err
}
h, err := windows.OpenProcess(windows.SYNCHRONIZE, false, uint32(pid))
- if err == windows.ERROR_ACCESS_DENIED {
+ if errors.Is(err, windows.ERROR_ACCESS_DENIED) {
return true, nil
}
- if err == windows.ERROR_INVALID_PARAMETER {
+ if errors.Is(err, windows.ERROR_INVALID_PARAMETER) {
return false, nil
}
if err != nil {
@@ -302,7 +302,7 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
return event == uint32(windows.WAIT_TIMEOUT), err
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
// if cached already, return from cache
cachedPpid := p.getPpid()
if cachedPpid != 0 {
@@ -330,17 +330,17 @@ func (p *Process) NameWithContext(ctx context.Context) (string, error) {
exe, err := p.ExeWithContext(ctx)
if err != nil {
- return "", fmt.Errorf("could not get Name: %s", err)
+ return "", fmt.Errorf("could not get Name: %w", err)
}
return filepath.Base(exe), nil
}
-func (p *Process) TgidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) TgidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
+func (p *Process) ExeWithContext(_ context.Context) (string, error) {
c, err := windows.OpenProcess(processQueryInformation, false, uint32(p.Pid))
if err != nil {
return "", err
@@ -357,20 +357,20 @@ func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
if ret == 0 {
return "", err
}
- return windows.UTF16ToString(buf[:]), nil
+ return windows.UTF16ToString(buf), nil
}
// XP fallback
ret, _, err := procGetProcessImageFileNameW.Call(uintptr(c), uintptr(unsafe.Pointer(&buf[0])), uintptr(size))
if ret == 0 {
return "", err
}
- return common.ConvertDOSPath(windows.UTF16ToString(buf[:])), nil
+ return common.ConvertDOSPath(windows.UTF16ToString(buf)), nil
}
func (p *Process) CmdlineWithContext(_ context.Context) (string, error) {
cmdline, err := getProcessCommandLine(p.Pid)
if err != nil {
- return "", fmt.Errorf("could not get CommandLine: %s", err)
+ return "", fmt.Errorf("could not get CommandLine: %w", err)
}
return cmdline, nil
}
@@ -380,13 +380,33 @@ func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error)
if err != nil {
return nil, err
}
- return strings.Split(cmdline, " "), nil
+ return parseCmdline(cmdline)
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func parseCmdline(cmdline string) ([]string, error) {
+ cmdlineptr, err := windows.UTF16PtrFromString(cmdline)
+ if err != nil {
+ return nil, err
+ }
+
+ var argc int32
+ argvptr, err := windows.CommandLineToArgv(cmdlineptr, &argc)
+ if err != nil {
+ return nil, err
+ }
+ defer windows.LocalFree(windows.Handle(uintptr(unsafe.Pointer(argvptr))))
+
+ argv := make([]string, argc)
+ for i, v := range (*argvptr)[:argc] {
+ argv[i] = windows.UTF16ToString((*v)[:])
+ }
+ return argv, nil
+}
+
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
ru, err := getRusage(p.Pid)
if err != nil {
- return 0, fmt.Errorf("could not get CreationDate: %s", err)
+ return 0, fmt.Errorf("could not get CreationDate: %w", err)
}
return ru.CreationTime.Nanoseconds() / 1000000, nil
@@ -394,7 +414,7 @@ func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
func (p *Process) CwdWithContext(_ context.Context) (string, error) {
h, err := windows.OpenProcess(processQueryInformation|windows.PROCESS_VM_READ, false, uint32(p.Pid))
- if err == windows.ERROR_ACCESS_DENIED || err == windows.ERROR_INVALID_PARAMETER {
+ if errors.Is(err, windows.ERROR_ACCESS_DENIED) || errors.Is(err, windows.ERROR_INVALID_PARAMETER) {
return "", nil
}
if err != nil {
@@ -436,15 +456,15 @@ func (p *Process) CwdWithContext(_ context.Context) (string, error) {
return "", nil
}
-func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) StatusWithContext(_ context.Context) ([]string, error) {
return []string{""}, common.ErrNotImplementedError
}
-func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
+func (p *Process) ForegroundWithContext(_ context.Context) (bool, error) {
return false, common.ErrNotImplementedError
}
-func (p *Process) UsernameWithContext(ctx context.Context) (string, error) {
+func (p *Process) UsernameWithContext(_ context.Context) (string, error) {
pid := p.Pid
c, err := windows.OpenProcess(processQueryInformation, false, uint32(pid))
if err != nil {
@@ -467,19 +487,19 @@ func (p *Process) UsernameWithContext(ctx context.Context) (string, error) {
return domain + "\\" + user, err
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
@@ -495,7 +515,7 @@ var priorityClasses = map[int]int32{
0x00000100: 24, // REALTIME_PRIORITY_CLASS
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
c, err := windows.OpenProcess(processQueryInformation, false, uint32(p.Pid))
if err != nil {
return 0, err
@@ -512,19 +532,19 @@ func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
return priority, nil
}
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) IOniceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
+func (p *Process) RlimitWithContext(_ context.Context) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
+func (p *Process) RlimitUsageWithContext(_ context.Context, _ bool) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
c, err := windows.OpenProcess(processQueryInformation, false, uint32(p.Pid))
if err != nil {
return nil, err
@@ -545,13 +565,13 @@ func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, e
return stats, nil
}
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
+func (p *Process) NumCtxSwitchesWithContext(_ context.Context) (*NumCtxSwitchesStat, error) {
return nil, common.ErrNotImplementedError
}
// NumFDsWithContext returns the number of handles for a process on Windows,
// not the number of file descriptors (FDs).
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumFDsWithContext(_ context.Context) (int32, error) {
handle, err := windows.OpenProcess(processQueryInformation, false, uint32(p.Pid))
if err != nil {
return 0, err
@@ -566,7 +586,7 @@ func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
return int32(handleCount), nil
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
ppid, ret, _, err := getFromSnapProcess(p.Pid)
if err != nil {
return 0, err
@@ -581,11 +601,11 @@ func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
return ret, nil
}
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
+func (p *Process) ThreadsWithContext(_ context.Context) (map[int32]*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
sysTimes, err := getProcessCPUTimes(p.Pid)
if err != nil {
return nil, err
@@ -609,11 +629,11 @@ func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error)
}, nil
}
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
+func (p *Process) CPUAffinityWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
+func (p *Process) MemoryInfoWithContext(_ context.Context) (*MemoryInfoStat, error) {
mem, err := getMemoryInfo(p.Pid)
if err != nil {
return nil, err
@@ -627,12 +647,22 @@ func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, e
return ret, nil
}
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
+func (p *Process) MemoryInfoExWithContext(_ context.Context) (*MemoryInfoExStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error) {
- return nil, common.ErrNotImplementedError
+func (p *Process) PageFaultsWithContext(_ context.Context) (*PageFaultsStat, error) {
+ mem, err := getMemoryInfo(p.Pid)
+ if err != nil {
+ return nil, err
+ }
+
+ ret := &PageFaultsStat{
+ // Since Windows does not distinguish between Major and Minor faults, all faults are treated as Major
+ MajorFaults: uint64(mem.PageFaultCount),
+ }
+
+ return ret, nil
}
func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
@@ -758,19 +788,19 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS
return net.ConnectionsPidWithContext(ctx, "all", p.Pid)
}
-func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsMaxWithContext(_ context.Context, _ int) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
+func (p *Process) MemoryMapsWithContext(_ context.Context, _ bool) (*[]MemoryMapsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) SendSignalWithContext(ctx context.Context, sig syscall.Signal) error {
+func (p *Process) SendSignalWithContext(_ context.Context, _ syscall.Signal) error {
return common.ErrNotImplementedError
}
-func (p *Process) SuspendWithContext(ctx context.Context) error {
+func (p *Process) SuspendWithContext(_ context.Context) error {
c, err := windows.OpenProcess(windows.PROCESS_SUSPEND_RESUME, false, uint32(p.Pid))
if err != nil {
return err
@@ -786,7 +816,7 @@ func (p *Process) SuspendWithContext(ctx context.Context) error {
return nil
}
-func (p *Process) ResumeWithContext(ctx context.Context) error {
+func (p *Process) ResumeWithContext(_ context.Context) error {
c, err := windows.OpenProcess(windows.PROCESS_SUSPEND_RESUME, false, uint32(p.Pid))
if err != nil {
return err
@@ -802,7 +832,7 @@ func (p *Process) ResumeWithContext(ctx context.Context) error {
return nil
}
-func (p *Process) TerminateWithContext(ctx context.Context) error {
+func (p *Process) TerminateWithContext(_ context.Context) error {
proc, err := windows.OpenProcess(windows.PROCESS_TERMINATE, false, uint32(p.Pid))
if err != nil {
return err
@@ -812,7 +842,7 @@ func (p *Process) TerminateWithContext(ctx context.Context) error {
return err
}
-func (p *Process) KillWithContext(ctx context.Context) error {
+func (p *Process) KillWithContext(_ context.Context) error {
process, err := os.FindProcess(int(p.Pid))
if err != nil {
return err
@@ -822,9 +852,9 @@ func (p *Process) KillWithContext(ctx context.Context) error {
}
func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) {
- envVars, err := getProcessEnvironmentVariables(p.Pid, ctx)
+ envVars, err := getProcessEnvironmentVariables(ctx, p.Pid)
if err != nil {
- return nil, fmt.Errorf("could not get environment variables: %s", err)
+ return nil, fmt.Errorf("could not get environment variables: %w", err)
}
return envVars, nil
}
@@ -844,7 +874,7 @@ func (p *Process) setPpid(ppid int32) {
p.parent = ppid
}
-func getFromSnapProcess(pid int32) (int32, int32, string, error) {
+func getFromSnapProcess(pid int32) (int32, int32, string, error) { //nolint:unparam //FIXME
snap, err := windows.CreateToolhelp32Snapshot(windows.TH32CS_SNAPPROCESS, uint32(pid))
if err != nil {
return 0, 0, "", err
@@ -872,7 +902,7 @@ func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
pids, err := PidsWithContext(ctx)
if err != nil {
- return out, fmt.Errorf("could not get Processes %s", err)
+ return out, fmt.Errorf("could not get Processes %w", err)
}
for _, pid := range pids {
@@ -928,7 +958,7 @@ func getProcessMemoryInfo(h windows.Handle, mem *PROCESS_MEMORY_COUNTERS) (err e
return
}
-type SYSTEM_TIMES struct {
+type SYSTEM_TIMES struct { //nolint:revive //FIXME
CreateTime syscall.Filetime
ExitTime syscall.Filetime
KernelTime syscall.Filetime
@@ -963,13 +993,13 @@ func getUserProcessParams32(handle windows.Handle) (rtlUserProcessParameters32,
buf := readProcessMemory(syscall.Handle(handle), true, pebAddress, uint(unsafe.Sizeof(processEnvironmentBlock32{})))
if len(buf) != int(unsafe.Sizeof(processEnvironmentBlock32{})) {
- return rtlUserProcessParameters32{}, fmt.Errorf("cannot read process PEB")
+ return rtlUserProcessParameters32{}, errors.New("cannot read process PEB")
}
peb := (*processEnvironmentBlock32)(unsafe.Pointer(&buf[0]))
userProcessAddress := uint64(peb.ProcessParameters)
buf = readProcessMemory(syscall.Handle(handle), true, userProcessAddress, uint(unsafe.Sizeof(rtlUserProcessParameters32{})))
if len(buf) != int(unsafe.Sizeof(rtlUserProcessParameters32{})) {
- return rtlUserProcessParameters32{}, fmt.Errorf("cannot read user process parameters")
+ return rtlUserProcessParameters32{}, errors.New("cannot read user process parameters")
}
return *(*rtlUserProcessParameters32)(unsafe.Pointer(&buf[0])), nil
}
@@ -982,13 +1012,13 @@ func getUserProcessParams64(handle windows.Handle) (rtlUserProcessParameters64,
buf := readProcessMemory(syscall.Handle(handle), false, pebAddress, uint(unsafe.Sizeof(processEnvironmentBlock64{})))
if len(buf) != int(unsafe.Sizeof(processEnvironmentBlock64{})) {
- return rtlUserProcessParameters64{}, fmt.Errorf("cannot read process PEB")
+ return rtlUserProcessParameters64{}, errors.New("cannot read process PEB")
}
peb := (*processEnvironmentBlock64)(unsafe.Pointer(&buf[0]))
userProcessAddress := peb.ProcessParameters
buf = readProcessMemory(syscall.Handle(handle), false, userProcessAddress, uint(unsafe.Sizeof(rtlUserProcessParameters64{})))
if len(buf) != int(unsafe.Sizeof(rtlUserProcessParameters64{})) {
- return rtlUserProcessParameters64{}, fmt.Errorf("cannot read user process parameters")
+ return rtlUserProcessParameters64{}, errors.New("cannot read user process parameters")
}
return *(*rtlUserProcessParameters64)(unsafe.Pointer(&buf[0])), nil
}
@@ -1038,9 +1068,9 @@ func is32BitProcess(h windows.Handle) bool {
return procIs32Bits
}
-func getProcessEnvironmentVariables(pid int32, ctx context.Context) ([]string, error) {
+func getProcessEnvironmentVariables(ctx context.Context, pid int32) ([]string, error) {
h, err := windows.OpenProcess(processQueryInformation|windows.PROCESS_VM_READ, false, uint32(pid))
- if err == windows.ERROR_ACCESS_DENIED || err == windows.ERROR_INVALID_PARAMETER {
+ if errors.Is(err, windows.ERROR_ACCESS_DENIED) || errors.Is(err, windows.ERROR_INVALID_PARAMETER) {
return nil, nil
}
if err != nil {
@@ -1124,7 +1154,7 @@ func (p *processReader) Read(buf []byte) (int, error) {
func getProcessCommandLine(pid int32) (string, error) {
h, err := windows.OpenProcess(processQueryInformation|windows.PROCESS_VM_READ, false, uint32(pid))
- if err == windows.ERROR_ACCESS_DENIED || err == windows.ERROR_INVALID_PARAMETER {
+ if errors.Is(err, windows.ERROR_ACCESS_DENIED) || errors.Is(err, windows.ERROR_INVALID_PARAMETER) {
return "", nil
}
if err != nil {
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_windows_32bit.go b/vendor/github.com/shirou/gopsutil/v4/process/process_windows_32bit.go
index 2b231c7..911351b 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_windows_32bit.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_windows_32bit.go
@@ -8,11 +8,12 @@ import (
"syscall"
"unsafe"
- "github.com/shirou/gopsutil/v4/internal/common"
"golang.org/x/sys/windows"
+
+ "github.com/shirou/gopsutil/v4/internal/common"
)
-type PROCESS_MEMORY_COUNTERS struct {
+type PROCESS_MEMORY_COUNTERS struct { //nolint:revive //FIXME
CB uint32
PageFaultCount uint32
PeakWorkingSetSize uint32
@@ -39,30 +40,27 @@ func queryPebAddress(procHandle syscall.Handle, is32BitProcess bool) (uint64, er
)
if status := windows.NTStatus(ret); status == windows.STATUS_SUCCESS {
return uint64(info.PebBaseAddress), nil
- } else {
- return 0, windows.NTStatus(ret)
}
- } else {
- // we are on a 32-bit process reading an external 64-bit process
- if common.ProcNtWow64QueryInformationProcess64.Find() == nil { // avoid panic
- var info processBasicInformation64
+ return 0, windows.NTStatus(ret)
+ }
+ // we are on a 32-bit process reading an external 64-bit process
+ if common.ProcNtWow64QueryInformationProcess64.Find() != nil {
+ return 0, errors.New("can't find API to query 64 bit process from 32 bit")
+ }
+ // avoid panic
+ var info processBasicInformation64
- ret, _, _ := common.ProcNtWow64QueryInformationProcess64.Call(
- uintptr(procHandle),
- uintptr(common.ProcessBasicInformation),
- uintptr(unsafe.Pointer(&info)),
- uintptr(unsafe.Sizeof(info)),
- uintptr(0),
- )
- if status := windows.NTStatus(ret); status == windows.STATUS_SUCCESS {
- return info.PebBaseAddress, nil
- } else {
- return 0, windows.NTStatus(ret)
- }
- } else {
- return 0, errors.New("can't find API to query 64 bit process from 32 bit")
- }
+ ret, _, _ := common.ProcNtWow64QueryInformationProcess64.Call(
+ uintptr(procHandle),
+ uintptr(common.ProcessBasicInformation),
+ uintptr(unsafe.Pointer(&info)),
+ uintptr(unsafe.Sizeof(info)),
+ uintptr(0),
+ )
+ if status := windows.NTStatus(ret); status == windows.STATUS_SUCCESS {
+ return info.PebBaseAddress, nil
}
+ return 0, windows.NTStatus(ret)
}
func readProcessMemory(h syscall.Handle, is32BitProcess bool, address uint64, size uint) []byte {
@@ -81,25 +79,23 @@ func readProcessMemory(h syscall.Handle, is32BitProcess bool, address uint64, si
if int(ret) >= 0 && read > 0 {
return buffer[:read]
}
- } else {
// reading a 64-bit process from a 32-bit one
- if common.ProcNtWow64ReadVirtualMemory64.Find() == nil { // avoid panic
- var read uint64
+ } else if common.ProcNtWow64ReadVirtualMemory64.Find() == nil { // avoid panic
+ var read uint64
- buffer := make([]byte, size)
+ buffer := make([]byte, size)
- ret, _, _ := common.ProcNtWow64ReadVirtualMemory64.Call(
- uintptr(h),
- uintptr(address&0xFFFFFFFF), // the call expects a 64-bit value
- uintptr(address>>32),
- uintptr(unsafe.Pointer(&buffer[0])),
- uintptr(size), // the call expects a 64-bit value
- uintptr(0), // but size is 32-bit so pass zero as the high dword
- uintptr(unsafe.Pointer(&read)),
- )
- if int(ret) >= 0 && read > 0 {
- return buffer[:uint(read)]
- }
+ ret, _, _ := common.ProcNtWow64ReadVirtualMemory64.Call(
+ uintptr(h),
+ uintptr(address&0xFFFFFFFF), // the call expects a 64-bit value
+ uintptr(address>>32),
+ uintptr(unsafe.Pointer(&buffer[0])),
+ uintptr(size), // the call expects a 64-bit value
+ uintptr(0), // but size is 32-bit so pass zero as the high dword
+ uintptr(unsafe.Pointer(&read)),
+ )
+ if int(ret) >= 0 && read > 0 {
+ return buffer[:uint(read)]
}
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_windows_64bit.go b/vendor/github.com/shirou/gopsutil/v4/process/process_windows_64bit.go
index befe521..8cc26c3 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_windows_64bit.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_windows_64bit.go
@@ -7,11 +7,12 @@ import (
"syscall"
"unsafe"
- "github.com/shirou/gopsutil/v4/internal/common"
"golang.org/x/sys/windows"
+
+ "github.com/shirou/gopsutil/v4/internal/common"
)
-type PROCESS_MEMORY_COUNTERS struct {
+type PROCESS_MEMORY_COUNTERS struct { //nolint:revive //FIXME
CB uint32
PageFaultCount uint32
PeakWorkingSetSize uint64
@@ -38,26 +39,23 @@ func queryPebAddress(procHandle syscall.Handle, is32BitProcess bool) (uint64, er
)
if status := windows.NTStatus(ret); status == windows.STATUS_SUCCESS {
return uint64(wow64), nil
- } else {
- return 0, windows.NTStatus(ret)
}
- } else {
- // we are on a 64-bit process reading an external 64-bit process
- var info processBasicInformation64
+ return 0, windows.NTStatus(ret)
+ }
+ // we are on a 64-bit process reading an external 64-bit process
+ var info processBasicInformation64
- ret, _, _ := common.ProcNtQueryInformationProcess.Call(
- uintptr(procHandle),
- uintptr(common.ProcessBasicInformation),
- uintptr(unsafe.Pointer(&info)),
- uintptr(unsafe.Sizeof(info)),
- uintptr(0),
- )
- if status := windows.NTStatus(ret); status == windows.STATUS_SUCCESS {
- return info.PebBaseAddress, nil
- } else {
- return 0, windows.NTStatus(ret)
- }
+ ret, _, _ := common.ProcNtQueryInformationProcess.Call(
+ uintptr(procHandle),
+ uintptr(common.ProcessBasicInformation),
+ uintptr(unsafe.Pointer(&info)),
+ uintptr(unsafe.Sizeof(info)),
+ uintptr(0),
+ )
+ if status := windows.NTStatus(ret); status == windows.STATUS_SUCCESS {
+ return info.PebBaseAddress, nil
}
+ return 0, windows.NTStatus(ret)
}
func readProcessMemory(procHandle syscall.Handle, _ bool, address uint64, size uint) []byte {