From a0955a9f6722e05a5a3b0f8370bf75ef090eda75 Mon Sep 17 00:00:00 2001 From: moein Date: Fri, 25 Aug 2023 03:44:18 +0430 Subject: [PATCH] Add iota for incremental data --- internal/go-ole/constants.go | 26 +++++++------- internal/gopsutil/cpu/cpu_darwin.go | 12 +++---- internal/gopsutil/cpu/cpu_solaris.go | 18 +++++----- internal/gopsutil/process/process.go | 34 +++++++++---------- .../gopsutil/process/process_freebsd_386.go | 14 ++++---- .../gopsutil/process/process_freebsd_amd64.go | 14 ++++---- .../gopsutil/process/process_freebsd_arm.go | 14 ++++---- .../gopsutil/process/process_freebsd_arm64.go | 14 ++++---- .../gopsutil/process/process_openbsd_386.go | 14 ++++---- .../gopsutil/process/process_openbsd_amd64.go | 14 ++++---- internal/gopsutil/process/types_openbsd.go | 14 ++++---- 11 files changed, 94 insertions(+), 94 deletions(-) diff --git a/internal/go-ole/constants.go b/internal/go-ole/constants.go index fd0c6d74b0..3d55d69bf6 100644 --- a/internal/go-ole/constants.go +++ b/internal/go-ole/constants.go @@ -19,10 +19,10 @@ const ( ) const ( - DISPATCH_METHOD = 1 - DISPATCH_PROPERTYGET = 2 - DISPATCH_PROPERTYPUT = 4 - DISPATCH_PROPERTYPUTREF = 8 + DISPATCH_METHOD = 1 << iota + DISPATCH_PROPERTYGET + DISPATCH_PROPERTYPUT + DISPATCH_PROPERTYPUTREF ) const ( @@ -124,15 +124,15 @@ const ( ) const ( - TKIND_ENUM = 1 - TKIND_RECORD = 2 - TKIND_MODULE = 3 - TKIND_INTERFACE = 4 - TKIND_DISPATCH = 5 - TKIND_COCLASS = 6 - TKIND_ALIAS = 7 - TKIND_UNION = 8 - TKIND_MAX = 9 + TKIND_ENUM = iota + 1 + TKIND_RECORD + TKIND_MODULE + TKIND_INTERFACE + TKIND_DISPATCH + TKIND_COCLASS + TKIND_ALIAS + TKIND_UNION + TKIND_MAX ) // Safe Array Feature Flags diff --git a/internal/gopsutil/cpu/cpu_darwin.go b/internal/gopsutil/cpu/cpu_darwin.go index 455857d536..e4d0961064 100644 --- a/internal/gopsutil/cpu/cpu_darwin.go +++ b/internal/gopsutil/cpu/cpu_darwin.go @@ -14,12 +14,12 @@ import ( // sys/resource.h const ( - CPUser = 0 - CPNice = 1 - CPSys = 2 - CPIntr = 3 - CPIdle = 4 - CPUStates = 5 + CPUser = iota + CPNice + CPSys + CPIntr + CPIdle + CPUStates ) // default value. from time.h diff --git a/internal/gopsutil/cpu/cpu_solaris.go b/internal/gopsutil/cpu/cpu_solaris.go index b7942cc0d0..b4cb55626b 100644 --- a/internal/gopsutil/cpu/cpu_solaris.go +++ b/internal/gopsutil/cpu/cpu_solaris.go @@ -187,15 +187,15 @@ func parseISAInfo(cmdOutput string) ([]string, error) { var psrInfoMatch = regexp.MustCompile(`The physical processor has (?:([\d]+) virtual processor \(([\d]+)\)|([\d]+) cores and ([\d]+) virtual processors[^\n]+)\n(?:\s+ The core has.+\n)*\s+.+ \((\w+) ([\S]+) family (.+) model (.+) step (.+) clock (.+) MHz\)\n[\s]*(.*)`) const ( - psrNumCoresOffset = 1 - psrNumCoresHTOffset = 3 - psrNumHTOffset = 4 - psrVendorIDOffset = 5 - psrFamilyOffset = 7 - psrModelOffset = 8 - psrStepOffset = 9 - psrClockOffset = 10 - psrModelNameOffset = 11 + psrNumCoresOffset = iota + 1 + psrNumCoresHTOffset + psrNumHTOffset + psrVendorIDOffset + psrFamilyOffset + psrModelOffset + psrStepOffset + psrClockOffset + psrModelNameOffset ) func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) { diff --git a/internal/gopsutil/process/process.go b/internal/gopsutil/process/process.go index bbf0fdf148..753b8f01b9 100644 --- a/internal/gopsutil/process/process.go +++ b/internal/gopsutil/process/process.go @@ -91,22 +91,22 @@ type PageFaultsStat struct { // Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h // from libc6-dev package in Ubuntu 16.10 const ( - RLIMIT_CPU int32 = 0 - RLIMIT_FSIZE int32 = 1 - RLIMIT_DATA int32 = 2 - RLIMIT_STACK int32 = 3 - RLIMIT_CORE int32 = 4 - RLIMIT_RSS int32 = 5 - RLIMIT_NPROC int32 = 6 - RLIMIT_NOFILE int32 = 7 - RLIMIT_MEMLOCK int32 = 8 - RLIMIT_AS int32 = 9 - RLIMIT_LOCKS int32 = 10 - RLIMIT_SIGPENDING int32 = 11 - RLIMIT_MSGQUEUE int32 = 12 - RLIMIT_NICE int32 = 13 - RLIMIT_RTPRIO int32 = 14 - RLIMIT_RTTIME int32 = 15 + RLIMIT_CPU int32 = iota + RLIMIT_FSIZE + RLIMIT_DATA + RLIMIT_STACK + RLIMIT_CORE + RLIMIT_RSS + RLIMIT_NPROC + RLIMIT_NOFILE + RLIMIT_MEMLOCK + RLIMIT_AS + RLIMIT_LOCKS + RLIMIT_SIGPENDING + RLIMIT_MSGQUEUE + RLIMIT_NICE + RLIMIT_RTPRIO + RLIMIT_RTTIME ) func (p Process) String() string { @@ -288,7 +288,7 @@ func (p *Process) MemoryPercentWithContext(ctx context.Context) (float32, error) } used := processMemory.RSS - return (100 * float32(used) / float32(total)), nil + return 100 * float32(used) / float32(total), nil } // CPU_Percent returns how many percent of the CPU time this process uses diff --git a/internal/gopsutil/process/process_freebsd_386.go b/internal/gopsutil/process/process_freebsd_386.go index 08ab333b43..3afb6c3672 100644 --- a/internal/gopsutil/process/process_freebsd_386.go +++ b/internal/gopsutil/process/process_freebsd_386.go @@ -26,13 +26,13 @@ const ( ) const ( - SIDL = 1 - SRUN = 2 - SSLEEP = 3 - SSTOP = 4 - SZOMB = 5 - SWAIT = 6 - SLOCK = 7 + SIDL = iota + 1 + SRUN + SSLEEP + SSTOP + SZOMB + SWAIT + SLOCK ) type ( diff --git a/internal/gopsutil/process/process_freebsd_amd64.go b/internal/gopsutil/process/process_freebsd_amd64.go index 560e627d24..6976c66019 100644 --- a/internal/gopsutil/process/process_freebsd_amd64.go +++ b/internal/gopsutil/process/process_freebsd_amd64.go @@ -26,13 +26,13 @@ const ( ) const ( - SIDL = 1 - SRUN = 2 - SSLEEP = 3 - SSTOP = 4 - SZOMB = 5 - SWAIT = 6 - SLOCK = 7 + SIDL = iota + 1 + SRUN + SSLEEP + SSTOP + SZOMB + SWAIT + SLOCK ) type ( diff --git a/internal/gopsutil/process/process_freebsd_arm.go b/internal/gopsutil/process/process_freebsd_arm.go index 81ae0b9a8d..f6cffb017b 100644 --- a/internal/gopsutil/process/process_freebsd_arm.go +++ b/internal/gopsutil/process/process_freebsd_arm.go @@ -26,13 +26,13 @@ const ( ) const ( - SIDL = 1 - SRUN = 2 - SSLEEP = 3 - SSTOP = 4 - SZOMB = 5 - SWAIT = 6 - SLOCK = 7 + SIDL = iota + 1 + SRUN + SSLEEP + SSTOP + SZOMB + SWAIT + SLOCK ) type ( diff --git a/internal/gopsutil/process/process_freebsd_arm64.go b/internal/gopsutil/process/process_freebsd_arm64.go index effd470a0c..653a19bada 100644 --- a/internal/gopsutil/process/process_freebsd_arm64.go +++ b/internal/gopsutil/process/process_freebsd_arm64.go @@ -29,13 +29,13 @@ const ( ) const ( - SIDL = 1 - SRUN = 2 - SSLEEP = 3 - SSTOP = 4 - SZOMB = 5 - SWAIT = 6 - SLOCK = 7 + SIDL = iota + 1 + SRUN + SSLEEP + SSTOP + SZOMB + SWAIT + SLOCK ) type ( diff --git a/internal/gopsutil/process/process_openbsd_386.go b/internal/gopsutil/process/process_openbsd_386.go index f4ed024917..34ae5de54c 100644 --- a/internal/gopsutil/process/process_openbsd_386.go +++ b/internal/gopsutil/process/process_openbsd_386.go @@ -36,13 +36,13 @@ const ( ) const ( - SIDL = 1 - SRUN = 2 - SSLEEP = 3 - SSTOP = 4 - SZOMB = 5 - SDEAD = 6 - SONPROC = 7 + SIDL = iota + 1 + SRUN + SSLEEP + SSTOP + SZOMB + SDEAD + SONPROC ) type ( diff --git a/internal/gopsutil/process/process_openbsd_amd64.go b/internal/gopsutil/process/process_openbsd_amd64.go index 8607422b5f..600a50aced 100644 --- a/internal/gopsutil/process/process_openbsd_amd64.go +++ b/internal/gopsutil/process/process_openbsd_amd64.go @@ -33,13 +33,13 @@ const ( ) const ( - SIDL = 1 - SRUN = 2 - SSLEEP = 3 - SSTOP = 4 - SZOMB = 5 - SDEAD = 6 - SONPROC = 7 + SIDL = iota + 1 + SRUN + SSLEEP + SSTOP + SZOMB + SDEAD + SONPROC ) type ( diff --git a/internal/gopsutil/process/types_openbsd.go b/internal/gopsutil/process/types_openbsd.go index 75f2344a9a..00c8940003 100644 --- a/internal/gopsutil/process/types_openbsd.go +++ b/internal/gopsutil/process/types_openbsd.go @@ -67,13 +67,13 @@ const ( // from sys/proc.h const ( - SIDL = 1 /* Process being created by fork. */ - SRUN = 2 /* Currently runnable. */ - SSLEEP = 3 /* Sleeping on an address. */ - SSTOP = 4 /* Process debugging or suspension. */ - SZOMB = 5 /* Awaiting collection by parent. */ - SDEAD = 6 /* Thread is almost gone */ - SONPROC = 7 /* Thread is currently on a CPU. */ + SIDL = iota + 1 /* Process being created by fork. */ + SRUN /* Currently runnable. */ + SSLEEP /* Sleeping on an address. */ + SSTOP /* Process debugging or suspension. */ + SZOMB /* Awaiting a collection by parent. */ + SDEAD /* Thread is almost gone */ + SONPROC /* Thread is currently on a CPU. */ ) // Basic types