Skip to content

Commit 46ae957

Browse files
authored
enable gosimple linter
1 parent 15ce718 commit 46ae957

File tree

7 files changed

+6
-11
lines changed

7 files changed

+6
-11
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ linters:
22
disable:
33
- deadcode
44
- errcheck
5-
- gosimple
65
- govet
76
- ineffassign
87
- staticcheck

v3/cpu/cpu_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func parseStatLine(line string) (*TimesStat, error) {
240240
return nil, errors.New("stat does not contain cpu info")
241241
}
242242

243-
if strings.HasPrefix(fields[0], "cpu") == false {
243+
if !strings.HasPrefix(fields[0], "cpu") {
244244
return nil, errors.New("not contain cpu")
245245
}
246246

v3/disk/disk_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC
349349
if err != nil {
350350
return nil, err
351351
}
352-
ret := make(map[string]IOCountersStat, 0)
352+
ret := make(map[string]IOCountersStat)
353353
empty := IOCountersStat{}
354354

355355
// use only basename such as "/dev/sda1" to "sda1"

v3/internal/common/common_unix.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ func CallLsofWithContext(ctx context.Context, invoke Invoker, pid int32, args ..
4141
}
4242

4343
func CallPgrepWithContext(ctx context.Context, invoke Invoker, pid int32) ([]int32, error) {
44-
var cmd []string
45-
cmd = []string{"-P", strconv.Itoa(int(pid))}
44+
cmd := []string{"-P", strconv.Itoa(int(pid))}
4645
pgrep, err := exec.LookPath("pgrep")
4746
if err != nil {
4847
return []int32{}, err

v3/net/net.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (l *ConntrackStatList) Append(c *ConntrackStat) {
131131
}
132132

133133
func (l *ConntrackStatList) Items() []ConntrackStat {
134-
items := make([]ConntrackStat, len(l.items), len(l.items))
134+
items := make([]ConntrackStat, len(l.items))
135135
for i, el := range l.items {
136136
items[i] = *el
137137
}

v3/net/net_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename stri
140140
ret = append(ret, nic)
141141
}
142142

143-
if pernic == false {
143+
if !pernic {
144144
return getIOCountersAll(ret)
145145
}
146146

v3/process/process_linux.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,10 +726,7 @@ func (p *Process) fillFromIOWithContext(ctx context.Context) (*IOCountersStat, e
726726
if err != nil {
727727
return nil, err
728728
}
729-
param := field[0]
730-
if strings.HasSuffix(param, ":") {
731-
param = param[:len(param)-1]
732-
}
729+
param := strings.TrimSuffix(field[0], ":")
733730
switch param {
734731
case "syscr":
735732
ret.ReadCount = t

0 commit comments

Comments
 (0)