From 051a2fe46de8630c87458c31646aab4a57f0c7d9 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Thu, 30 Jan 2025 07:43:24 +0100 Subject: [PATCH] chore: enable unused-parameter from revive Signed-off-by: Matthieu MOREL --- .golangci.yml | 1 - cpu/cpu_darwin.go | 6 +-- cpu/cpu_windows.go | 2 +- disk/disk_darwin.go | 8 ++-- disk/disk_unix.go | 2 +- disk/disk_windows.go | 10 ++--- docker/docker_linux_test.go | 4 +- docker/docker_notlinux.go | 8 ++-- docker/main_test.go | 2 +- host/host_bsd.go | 2 +- host/host_darwin.go | 6 +-- host/host_linux.go | 4 +- host/host_windows.go | 10 ++--- internal/common/common.go | 2 +- load/load_darwin.go | 2 +- load/load_windows.go | 2 +- mem/mem_darwin.go | 6 +-- mem/mem_windows.go | 6 +-- net/net.go | 2 +- net/net_darwin.go | 10 ++--- net/net_linux.go | 2 +- net/net_unix.go | 6 +-- net/net_windows.go | 14 +++---- process/process_bsd.go | 26 ++++++------- process/process_darwin.go | 28 +++++++------- process/process_linux.go | 4 +- process/process_posix.go | 2 +- process/process_windows.go | 66 ++++++++++++++++----------------- sensors/sensors_darwin_arm64.go | 2 +- winservices/winservices.go | 4 +- 30 files changed, 124 insertions(+), 125 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 33c8c3e55..47bfef3c4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -94,7 +94,6 @@ linters-settings: disabled: true - name: unreachable-code - name: unused-parameter - disabled: true - name: use-any - name: var-declaration - name: var-naming diff --git a/cpu/cpu_darwin.go b/cpu/cpu_darwin.go index b3e3a668d..91bac66f9 100644 --- a/cpu/cpu_darwin.go +++ b/cpu/cpu_darwin.go @@ -59,7 +59,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 +78,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 +121,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" diff --git a/cpu/cpu_windows.go b/cpu/cpu_windows.go index a71df97fe..c839ea461 100644 --- a/cpu/cpu_windows.go +++ b/cpu/cpu_windows.go @@ -58,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() } diff --git a/disk/disk_darwin.go b/disk/disk_darwin.go index 94f10b9fb..39fccff6b 100644 --- a/disk/disk_darwin.go +++ b/disk/disk_darwin.go @@ -16,7 +16,7 @@ import ( // PartitionsWithContext returns disk partition. // 'all' argument is ignored, see: https://github.com/giampaolo/psutil/issues/906 -func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) { +func PartitionsWithContext(_ context.Context, _ bool) ([]PartitionStat, error) { var ret []PartitionStat count, err := unix.Getfsstat(nil, unix.MNT_WAIT) @@ -88,15 +88,15 @@ func getFsType(stat unix.Statfs_t) string { return common.ByteToString(stat.Fstypename[:]) } -func SerialNumberWithContext(ctx context.Context, name string) (string, error) { +func SerialNumberWithContext(_ context.Context, _ string) (string, error) { return "", common.ErrNotImplementedError } -func LabelWithContext(ctx context.Context, name string) (string, error) { +func LabelWithContext(_ context.Context, _ string) (string, error) { return "", common.ErrNotImplementedError } -func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) { +func IOCountersWithContext(_ context.Context, names ...string) (map[string]IOCountersStat, error) { ioKit, err := common.NewLibrary(common.IOKit) if err != nil { return nil, err diff --git a/disk/disk_unix.go b/disk/disk_unix.go index d69d83817..482372da2 100644 --- a/disk/disk_unix.go +++ b/disk/disk_unix.go @@ -10,7 +10,7 @@ import ( "golang.org/x/sys/unix" ) -func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) { +func UsageWithContext(_ context.Context, path string) (*UsageStat, error) { stat := unix.Statfs_t{} err := unix.Statfs(path, &stat) if err != nil { diff --git a/disk/disk_windows.go b/disk/disk_windows.go index 5f2438941..b9343cb2b 100644 --- a/disk/disk_windows.go +++ b/disk/disk_windows.go @@ -55,7 +55,7 @@ func init() { } } -func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) { +func UsageWithContext(_ context.Context, path string) (*UsageStat, error) { lpFreeBytesAvailable := int64(0) lpTotalNumberOfBytes := int64(0) lpTotalNumberOfFreeBytes := int64(0) @@ -83,7 +83,7 @@ func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) { // PartitionsWithContext returns disk partitions. // Since GetVolumeInformation doesn't have a timeout, this method uses context to set deadline by users. -func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) { +func PartitionsWithContext(ctx context.Context, _ bool) ([]PartitionStat, error) { warnings := Warnings{ Verbose: true, } @@ -182,7 +182,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro } } -func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) { +func IOCountersWithContext(_ context.Context, names ...string) (map[string]IOCountersStat, error) { // https://github.com/giampaolo/psutil/blob/544e9daa4f66a9f80d7bf6c7886d693ee42f0a13/psutil/arch/windows/disk.c#L83 drivemap := make(map[string]IOCountersStat, 0) var diskPerformance diskPerformance @@ -236,10 +236,10 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC return drivemap, nil } -func SerialNumberWithContext(ctx context.Context, name string) (string, error) { +func SerialNumberWithContext(_ context.Context, _ string) (string, error) { return "", common.ErrNotImplementedError } -func LabelWithContext(ctx context.Context, name string) (string, error) { +func LabelWithContext(_ context.Context, _ string) (string, error) { return "", common.ErrNotImplementedError } diff --git a/docker/docker_linux_test.go b/docker/docker_linux_test.go index 2d0f35b03..f1cf3e0ca 100644 --- a/docker/docker_linux_test.go +++ b/docker/docker_linux_test.go @@ -8,7 +8,7 @@ import ( "testing" ) -func TestGetDockerIDList(t *testing.T) { +func TestGetDockerIDList(_ *testing.T) { // If there is not docker environment, this test always fail. // not tested here /* @@ -19,7 +19,7 @@ func TestGetDockerIDList(t *testing.T) { */ } -func TestGetDockerStat(t *testing.T) { +func TestGetDockerStat(_ *testing.T) { // If there is not docker environment, this test always fail. // not tested here diff --git a/docker/docker_notlinux.go b/docker/docker_notlinux.go index ca7a7f914..9627e0439 100644 --- a/docker/docker_notlinux.go +++ b/docker/docker_notlinux.go @@ -15,7 +15,7 @@ func GetDockerStat() ([]CgroupDockerStat, error) { return GetDockerStatWithContext(context.Background()) } -func GetDockerStatWithContext(ctx context.Context) ([]CgroupDockerStat, error) { +func GetDockerStatWithContext(_ context.Context) ([]CgroupDockerStat, error) { return nil, ErrDockerNotAvailable } @@ -25,7 +25,7 @@ func GetDockerIDList() ([]string, error) { return GetDockerIDListWithContext(context.Background()) } -func GetDockerIDListWithContext(ctx context.Context) ([]string, error) { +func GetDockerIDListWithContext(_ context.Context) ([]string, error) { return nil, ErrDockerNotAvailable } @@ -37,7 +37,7 @@ func CgroupCPU(containerid string, base string) (*CgroupCPUStat, error) { return CgroupCPUWithContext(context.Background(), containerid, base) } -func CgroupCPUWithContext(ctx context.Context, containerid string, base string) (*CgroupCPUStat, error) { +func CgroupCPUWithContext(_ context.Context, _ string, _ string) (*CgroupCPUStat, error) { return nil, ErrCgroupNotAvailable } @@ -53,7 +53,7 @@ func CgroupMem(containerid string, base string) (*CgroupMemStat, error) { return CgroupMemWithContext(context.Background(), containerid, base) } -func CgroupMemWithContext(ctx context.Context, containerid string, base string) (*CgroupMemStat, error) { +func CgroupMemWithContext(_ context.Context, _ string, _ string) (*CgroupMemStat, error) { return nil, ErrCgroupNotAvailable } diff --git a/docker/main_test.go b/docker/main_test.go index 14ee18689..98fac9461 100644 --- a/docker/main_test.go +++ b/docker/main_test.go @@ -6,7 +6,7 @@ import ( "testing" ) -func TestSysAdvancedDockerInfo(t *testing.T) { +func TestSysAdvancedDockerInfo(_ *testing.T) { list, err := GetDockerIDList() if err != nil { fmt.Println(err) diff --git a/host/host_bsd.go b/host/host_bsd.go index b67f8fb6e..4d27ed621 100644 --- a/host/host_bsd.go +++ b/host/host_bsd.go @@ -13,7 +13,7 @@ import ( // cachedBootTime must be accessed via atomic.Load/StoreUint64 var cachedBootTime uint64 -func BootTimeWithContext(ctx context.Context) (uint64, error) { +func BootTimeWithContext(_ context.Context) (uint64, error) { if enableBootTimeCache { t := atomic.LoadUint64(&cachedBootTime) if t != 0 { diff --git a/host/host_darwin.go b/host/host_darwin.go index 068f1060a..977426d43 100644 --- a/host/host_darwin.go +++ b/host/host_darwin.go @@ -49,7 +49,7 @@ func numProcs(ctx context.Context) (uint64, error) { return uint64(len(procs)), nil } -func UsersWithContext(ctx context.Context) ([]UserStat, error) { +func UsersWithContext(_ context.Context) ([]UserStat, error) { utmpfile := "/var/run/utmpx" var ret []UserStat @@ -123,11 +123,11 @@ func PlatformInformationWithContext(ctx context.Context) (string, string, string return platform, family, pver, nil } -func VirtualizationWithContext(ctx context.Context) (string, string, error) { +func VirtualizationWithContext(_ context.Context) (string, string, error) { return "", "", common.ErrNotImplementedError } -func KernelVersionWithContext(ctx context.Context) (string, error) { +func KernelVersionWithContext(_ context.Context) (string, error) { version, err := unix.Sysctl("kern.osrelease") return strings.ToLower(version), err } diff --git a/host/host_linux.go b/host/host_linux.go index dd03f1555..f2cb0e570 100644 --- a/host/host_linux.go +++ b/host/host_linux.go @@ -70,7 +70,7 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) { return common.BootTimeWithContext(ctx, enableBootTimeCache) } -func UptimeWithContext(ctx context.Context) (uint64, error) { +func UptimeWithContext(_ context.Context) (uint64, error) { sysinfo := &unix.Sysinfo_t{} if err := unix.Sysinfo(sysinfo); err != nil { return 0, err @@ -322,7 +322,7 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil return platform, family, version, nil } -func KernelVersionWithContext(ctx context.Context) (version string, err error) { +func KernelVersionWithContext(_ context.Context) (version string, err error) { var utsname unix.Utsname err = unix.Uname(&utsname) if err != nil { diff --git a/host/host_windows.go b/host/host_windows.go index 41f4b7f02..3e8d0b1cd 100644 --- a/host/host_windows.go +++ b/host/host_windows.go @@ -56,7 +56,7 @@ type systemInfo struct { wProcessorRevision uint16 } -func HostIDWithContext(ctx context.Context) (string, error) { +func HostIDWithContext(_ context.Context) (string, error) { // there has been reports of issues on 32bit using golang.org/x/sys/windows/registry, see https://github.com/shirou/gopsutil/pull/312#issuecomment-277422612 // for rationale of using windows.RegOpenKeyEx/RegQueryValueEx instead of registry.OpenKey/GetStringValue var h windows.Handle @@ -94,7 +94,7 @@ func numProcs(ctx context.Context) (uint64, error) { return uint64(len(procs)), nil } -func UptimeWithContext(ctx context.Context) (uint64, error) { +func UptimeWithContext(_ context.Context) (uint64, error) { up, err := uptimeMillis() if err != nil { return 0, err @@ -118,7 +118,7 @@ func uptimeMillis() (uint64, error) { // cachedBootTime must be accessed via atomic.Load/StoreUint64 var cachedBootTime uint64 -func BootTimeWithContext(ctx context.Context) (uint64, error) { +func BootTimeWithContext(_ context.Context) (uint64, error) { if enableBootTimeCache { t := atomic.LoadUint64(&cachedBootTime) if t != 0 { @@ -234,13 +234,13 @@ func platformInformation() (platform, family, version, displayVersion string, er return platform, family, version, displayVersion, nil } -func UsersWithContext(ctx context.Context) ([]UserStat, error) { +func UsersWithContext(_ context.Context) ([]UserStat, error) { var ret []UserStat return ret, common.ErrNotImplementedError } -func VirtualizationWithContext(ctx context.Context) (string, string, error) { +func VirtualizationWithContext(_ context.Context) (string, string, error) { return "", "", common.ErrNotImplementedError } diff --git a/internal/common/common.go b/internal/common/common.go index 39816031c..8b9fb5339 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -93,7 +93,7 @@ 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...) } diff --git a/load/load_darwin.go b/load/load_darwin.go index fb7d5c09c..e07ec3a5d 100644 --- a/load/load_darwin.go +++ b/load/load_darwin.go @@ -15,7 +15,7 @@ func Avg() (*AvgStat, error) { return AvgWithContext(context.Background()) } -func AvgWithContext(ctx context.Context) (*AvgStat, error) { +func AvgWithContext(_ context.Context) (*AvgStat, error) { // This SysctlRaw method borrowed from // https://github.com/prometheus/node_exporter/blob/master/collector/loadavg_freebsd.go // this implementation is common with BSDs diff --git a/load/load_windows.go b/load/load_windows.go index f430d2aa7..c9e8a5250 100644 --- a/load/load_windows.go +++ b/load/load_windows.go @@ -86,7 +86,7 @@ func Misc() (*MiscStat, error) { return MiscWithContext(context.Background()) } -func MiscWithContext(ctx context.Context) (*MiscStat, error) { +func MiscWithContext(_ context.Context) (*MiscStat, error) { ret := MiscStat{} return &ret, common.ErrNotImplementedError diff --git a/mem/mem_darwin.go b/mem/mem_darwin.go index a4c15f691..7d96a3bb0 100644 --- a/mem/mem_darwin.go +++ b/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/mem/mem_windows.go b/mem/mem_windows.go index d7dcef4d7..015c1a19c 100644 --- a/mem/mem_windows.go +++ b/mem/mem_windows.go @@ -37,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))) @@ -77,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 { @@ -151,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/net/net.go b/net/net.go index 74af54a45..b4fff6e7a 100644 --- a/net/net.go +++ b/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 diff --git a/net/net_darwin.go b/net/net_darwin.go index f640931f2..8a3f3ec4c 100644 --- a/net/net_darwin.go +++ b/net/net_darwin.go @@ -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 } @@ -254,18 +254,18 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, 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/net/net_linux.go b/net/net_linux.go index 23113fea7..967ef4b7c 100644 --- a/net/net_linux.go +++ b/net/net_linux.go @@ -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 diff --git a/net/net_unix.go b/net/net_unix.go index 6eb7e2fc5..ae7e9d81a 100644 --- a/net/net_unix.go +++ b/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/net/net_windows.go b/net/net_windows.go index aa3cb6731..f0a784fb6 100644 --- a/net/net_windows.go +++ b/net/net_windows.go @@ -138,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 @@ -198,7 +198,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, return counters, nil } -func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) { +func IOCountersByFileWithContext(_ context.Context, pernic bool, _ string) ([]IOCountersStat, error) { return IOCounters(pernic) //nolint:contextcheck //FIXME } @@ -206,7 +206,7 @@ func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, 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) @@ -258,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 } @@ -290,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 } diff --git a/process/process_bsd.go b/process/process_bsd.go index dcc056101..1a58c3eca 100644 --- a/process/process_bsd.go +++ b/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/process/process_darwin.go b/process/process_darwin.go index 2c14f2e09..c453b2cdb 100644 --- a/process/process_darwin.go +++ b/process/process_darwin.go @@ -37,7 +37,7 @@ type _Ctype_struct___0 struct { 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") @@ -52,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 @@ -85,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 @@ -113,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 @@ -125,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 @@ -137,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 { @@ -152,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() @@ -170,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 @@ -178,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 } @@ -304,7 +304,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 @@ -333,7 +333,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 @@ -430,7 +430,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 @@ -443,7 +443,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 @@ -462,7 +462,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/process/process_linux.go b/process/process_linux.go index 68a8c88c4..bf96fd386 100644 --- a/process/process_linux.go +++ b/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/process/process_posix.go b/process/process_posix.go index 96c5e065c..6712f95d0 100644 --- a/process/process_posix.go +++ b/process/process_posix.go @@ -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/process/process_windows.go b/process/process_windows.go index 00b223627..83b50c0cc 100644 --- a/process/process_windows.go +++ b/process/process_windows.go @@ -242,7 +242,7 @@ 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 @@ -303,7 +303,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 { @@ -337,11 +337,11 @@ func (p *Process) NameWithContext(ctx context.Context) (string, error) { 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 @@ -384,7 +384,7 @@ func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) return strings.Split(cmdline, " "), nil } -func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) { +func (p *Process) createTimeWithContext(_ context.Context) (int64, error) { ru, err := getRusage(p.Pid) if err != nil { return 0, fmt.Errorf("could not get CreationDate: %w", err) @@ -437,15 +437,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 { @@ -468,19 +468,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 } @@ -496,7 +496,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 @@ -513,19 +513,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 @@ -546,13 +546,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 @@ -567,7 +567,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 @@ -582,11 +582,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 @@ -610,11 +610,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 @@ -628,11 +628,11 @@ 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) { +func (p *Process) PageFaultsWithContext(_ context.Context) (*PageFaultsStat, error) { return nil, common.ErrNotImplementedError } @@ -759,19 +759,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 @@ -787,7 +787,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 @@ -803,7 +803,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 @@ -813,7 +813,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 diff --git a/sensors/sensors_darwin_arm64.go b/sensors/sensors_darwin_arm64.go index 37158323e..8dcf0ea80 100644 --- a/sensors/sensors_darwin_arm64.go +++ b/sensors/sensors_darwin_arm64.go @@ -15,7 +15,7 @@ func ReadTemperaturesArm() []TemperatureStat { return temperatures } -func TemperaturesWithContext(ctx context.Context) ([]TemperatureStat, error) { +func TemperaturesWithContext(_ context.Context) ([]TemperatureStat, error) { ioKit, err := common.NewLibrary(common.IOKit) if err != nil { return nil, err diff --git a/winservices/winservices.go b/winservices/winservices.go index 1c062652d..1c1e1ed35 100644 --- a/winservices/winservices.go +++ b/winservices/winservices.go @@ -72,7 +72,7 @@ func (s *Service) QueryServiceConfig() (mgr.Config, error) { // QueryServiceConfigWithContext call QueryServiceConfig() and QueryServiceConfig2() // implement windows https://msdn.microsoft.com/en-us/library/windows/desktop/ms684932(v=vs.85).aspx -func (s *Service) QueryServiceConfigWithContext(ctx context.Context) (mgr.Config, error) { +func (s *Service) QueryServiceConfigWithContext(_ context.Context) (mgr.Config, error) { return s.srv.Config() } @@ -82,7 +82,7 @@ func (s *Service) QueryStatus() (ServiceStatus, error) { } // QueryStatusWithContext return the specified name service currentState and ControlsAccepted -func (s *Service) QueryStatusWithContext(ctx context.Context) (ServiceStatus, error) { +func (s *Service) QueryStatusWithContext(_ context.Context) (ServiceStatus, error) { var p *windows.SERVICE_STATUS_PROCESS var bytesNeeded uint32 var buf []byte