Skip to content

Commit 4bea90c

Browse files
authored
Merge pull request #1942 from shirou/fix/linter_error
fix: linter error about string concat and build tag
2 parents 065d285 + 5683c90 commit 4bea90c

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

host/host_aix_ppc64.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build aix && ppc64 && cgo
2-
// +build aix,ppc64,cgo
32

43
// Guessed at from the following document:
54
// https://www.ibm.com/docs/sl/ibm-mq/9.2?topic=platforms-standard-data-types-aix-linux-windows

internal/common/warnings.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// SPDX-License-Identifier: BSD-3-Clause
22
package common
33

4-
import "fmt"
4+
import (
5+
"fmt"
6+
"strings"
7+
)
58

69
const (
710
maxWarnings = 100 // An arbitrary limit to avoid excessive memory usage, it has no sense to store hundreds of errors
@@ -33,9 +36,11 @@ func (w *Warnings) Reference() error {
3336
func (w *Warnings) Error() string {
3437
if w.Verbose {
3538
str := ""
39+
var sb strings.Builder
3640
for i, e := range w.List {
37-
str += fmt.Sprintf("\tError %d: %s\n", i, e.Error())
41+
sb.WriteString(fmt.Sprintf("\tError %d: %s\n", i, e.Error()))
3842
}
43+
str += sb.String()
3944
if w.tooManyErrors {
4045
str += fmt.Sprintf("\t%s\n", tooManyErrorsMessage)
4146
}

net/net_linux.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,25 @@ func IOCountersByFileWithContext(_ context.Context, pernic bool, filename string
5050
return nil, err
5151
}
5252

53-
parts := make([]string, 2)
54-
5553
statlen := len(lines) - 1
5654

5755
ret := make([]IOCountersStat, 0, statlen)
5856

5957
for _, line := range lines[2:] {
58+
// Split interface name and stats data at the last ":"
6059
separatorPos := strings.LastIndex(line, ":")
6160
if separatorPos == -1 {
6261
continue
6362
}
64-
parts[0] = line[0:separatorPos]
65-
parts[1] = line[separatorPos+1:]
63+
interfacePart := line[0:separatorPos]
64+
statsPart := line[separatorPos+1:]
6665

67-
interfaceName := strings.TrimSpace(parts[0])
66+
interfaceName := strings.TrimSpace(interfacePart)
6867
if interfaceName == "" {
6968
continue
7069
}
7170

72-
fields := strings.Fields(strings.TrimSpace(parts[1]))
71+
fields := strings.Fields(strings.TrimSpace(statsPart))
7372
bytesRecv, err := strconv.ParseUint(fields[0], 10, 64)
7473
if err != nil {
7574
return ret, err

0 commit comments

Comments
 (0)