Skip to content

Commit

Permalink
Merge pull request #1417 from shirou/feature/fix_lint
Browse files Browse the repository at this point in the history
fix lint
  • Loading branch information
shirou authored Feb 12, 2023
2 parents 6a5e40a + 852f455 commit 57bee82
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 41 deletions.
22 changes: 11 additions & 11 deletions cpu/cpu_aix_nocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package cpu
import (
"context"
"regexp"
"strings"
"strconv"
"strings"

"github.com/shirou/gopsutil/v3/internal/common"
)
Expand All @@ -28,19 +28,19 @@ func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
}

ret := TimesStat{CPU: "cpu-total"}
h := whiteSpaces.Split(lines[len(lines)-3], -1) // headers
v := whiteSpaces.Split(lines[len(lines)-2], -1) // values
h := whiteSpaces.Split(lines[len(lines)-3], -1) // headers
v := whiteSpaces.Split(lines[len(lines)-2], -1) // values
for i, header := range h {
if t, err := strconv.ParseFloat(v[i], 64); err == nil {
switch header {
case `%usr`:
ret.User = t
case `%sys`:
ret.System = t
case `%wio`:
ret.Iowait = t
case `%idle`:
ret.Idle = t
case `%usr`:
ret.User = t
case `%sys`:
ret.System = t
case `%wio`:
ret.Iowait = t
case `%idle`:
ret.Idle = t
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions disk/disk_aix_nocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ import (
"regexp"
"strings"

"golang.org/x/sys/unix"
"github.com/shirou/gopsutil/v3/internal/common"
"golang.org/x/sys/unix"
)

var whiteSpaces = regexp.MustCompile(`\s+`)
var startBlank = regexp.MustCompile(`^\s+`)

var ignoreFSType = map[string]bool{"procfs": true}
var FSType = map[int]string{
0: "jfs2", 1: "namefs", 2: "nfs", 3: "jfs", 5: "cdrom", 6: "proc",
16: "special-fs", 17: "cache-fs", 18: "nfs3", 19: "automount-fs", 20: "pool-fs", 32: "vxfs",
33: "veritas-fs", 34: "udfs", 35: "nfs4", 36: "nfs4-pseudo", 37: "smbfs", 38: "mcr-pseudofs",
39: "ahafs", 40: "sterm-nfs", 41: "asmfs",
}
0: "jfs2", 1: "namefs", 2: "nfs", 3: "jfs", 5: "cdrom", 6: "proc",
16: "special-fs", 17: "cache-fs", 18: "nfs3", 19: "automount-fs", 20: "pool-fs", 32: "vxfs",
33: "veritas-fs", 34: "udfs", 35: "nfs4", 36: "nfs4-pseudo", 37: "smbfs", 38: "mcr-pseudofs",
39: "ahafs", 40: "sterm-nfs", 41: "asmfs",
}

func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
var ret []PartitionStat
Expand All @@ -42,7 +42,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
start := 0
finished := false
for pos, ch := range lines[1] {
if ch == ' ' && ! finished {
if ch == ' ' && !finished {
name := strings.TrimSpace(lines[0][start:pos])
colidx[name] = idx
finished = true
Expand Down
3 changes: 1 addition & 2 deletions disk/disk_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import (
"strconv"
"strings"

"golang.org/x/sys/unix"

"github.com/shirou/gopsutil/v3/internal/common"
"golang.org/x/sys/unix"
)

// PartitionsWithContext returns disk partition.
Expand Down
1 change: 1 addition & 0 deletions internal/common/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package common
// high-performance serialization, especially for large data structures,
// should look at more advanced solutions such as the encoding/gob
// package or protocol buffers.

import (
"errors"
"io"
Expand Down
1 change: 1 addition & 0 deletions internal/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package common
// - linux (amd64, arm)
// - freebsd (amd64)
// - windows (amd64)

import (
"bufio"
"bytes"
Expand Down
7 changes: 5 additions & 2 deletions internal/common/common_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,12 @@ func WMIQueryWithContext(ctx context.Context, query string, dst interface{}, con
}

// Convert paths using native DOS format like:
// "\Device\HarddiskVolume1\Windows\systemew\file.txt"
//
// "\Device\HarddiskVolume1\Windows\systemew\file.txt"
//
// into:
// "C:\Windows\systemew\file.txt"
//
// "C:\Windows\systemew\file.txt"
func ConvertDOSPath(p string) string {
rawDrive := strings.Join(strings.Split(p, `\`)[:3], `\`)

Expand Down
14 changes: 7 additions & 7 deletions load/load_aix_nocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ func MiscWithContext(ctx context.Context) (*MiscStat, error) {
for _, line := range strings.Split(string(out), "\n") {
ret.ProcsTotal++
switch line {
case "R":
case "A":
ret.ProcsRunning++
case "T":
ret.ProcsBlocked++
default:
continue
case "R":
case "A":
ret.ProcsRunning++
case "T":
ret.ProcsBlocked++
default:
continue
}
}
return ret, nil
Expand Down
2 changes: 1 addition & 1 deletion mem/mem_aix_nocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func callSVMon(ctx context.Context) (*VirtualMemoryStat, *SwapMemoryStat, error)
swap.Total = t * pagesize
}
if t, err := strconv.ParseUint(p[3], 10, 64); err == nil {
swap.Free = swap.Total - t * pagesize
swap.Free = swap.Total - t*pagesize
}
}
break
Expand Down
3 changes: 1 addition & 2 deletions mem/mem_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import (
"errors"
"unsafe"

"golang.org/x/sys/unix"

"github.com/shirou/gopsutil/v3/internal/common"
"golang.org/x/sys/unix"
)

func VirtualMemory() (*VirtualMemoryStat, error) {
Expand Down
1 change: 1 addition & 0 deletions mem/mem_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"encoding/binary"
"errors"
"fmt"

"github.com/shirou/gopsutil/v3/internal/common"
"golang.org/x/sys/unix"
)
Expand Down
12 changes: 6 additions & 6 deletions net/net_aix_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
iocounters := make([]IOCountersStat, 0, len(ifs))
for _, netif := range ifs {
n := IOCountersStat{
Name: netif.Name,
BytesSent: uint64(netif.OBytes),
BytesRecv: uint64(netif.IBytes),
Name: netif.Name,
BytesSent: uint64(netif.OBytes),
BytesRecv: uint64(netif.IBytes),
PacketsSent: uint64(netif.OPackets),
PacketsRecv: uint64(netif.IPackets),
Errin: uint64(netif.OErrors),
Errout: uint64(netif.IErrors),
Dropout: uint64(netif.XmitDrops),
Errin: uint64(netif.OErrors),
Errout: uint64(netif.IErrors),
Dropout: uint64(netif.XmitDrops),
}
iocounters = append(iocounters, n)
}
Expand Down
3 changes: 2 additions & 1 deletion net/net_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename stri

// Return a list of network connections
// Available kind:
// reference to netConnectionKindMap
//
// reference to netConnectionKindMap
func Connections(kind string) ([]ConnectionStat, error) {
return ConnectionsWithContext(context.Background(), kind)
}
Expand Down
3 changes: 1 addition & 2 deletions process/process_windows_32bit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import (
"syscall"
"unsafe"

"golang.org/x/sys/windows"

"github.com/shirou/gopsutil/v3/internal/common"
"golang.org/x/sys/windows"
)

type PROCESS_MEMORY_COUNTERS struct {
Expand Down

0 comments on commit 57bee82

Please sign in to comment.