diff --git a/pkg/ioutils/fswriters_test.go b/pkg/ioutils/fswriters_test.go index c4d1419306a47..5d286005d20db 100644 --- a/pkg/ioutils/fswriters_test.go +++ b/pkg/ioutils/fswriters_test.go @@ -37,7 +37,7 @@ func TestAtomicWriteToFile(t *testing.T) { t.Fatalf("Error reading from file: %v", err) } - if bytes.Compare(actual, expected) != 0 { + if !bytes.Equal(actual, expected) { t.Fatalf("Data mismatch, expected %q, got %q", expected, actual) } @@ -85,7 +85,7 @@ func TestAtomicWriteSetCommit(t *testing.T) { t.Fatalf("Error reading from file: %v", err) } - if bytes.Compare(actual, expected) != 0 { + if !bytes.Equal(actual, expected) { t.Fatalf("Data mismatch, expected %q, got %q", expected, actual) } diff --git a/pkg/ioutils/multireader_test.go b/pkg/ioutils/multireader_test.go index 65309a956530b..86ce47a226448 100644 --- a/pkg/ioutils/multireader_test.go +++ b/pkg/ioutils/multireader_test.go @@ -193,7 +193,7 @@ func TestMultiReadSeekerCurAfterSet(t *testing.T) { func TestMultiReadSeekerSmallReads(t *testing.T) { readers := []io.ReadSeeker{} for i := 0; i < 10; i++ { - integer := make([]byte, 4, 4) + integer := make([]byte, 4) binary.BigEndian.PutUint32(integer, uint32(i)) readers = append(readers, bytes.NewReader(integer)) } diff --git a/pkg/jsonlog/jsonlogbytes.go b/pkg/jsonlog/jsonlogbytes.go index df522c0d66f5c..0ba716f2611c0 100644 --- a/pkg/jsonlog/jsonlogbytes.go +++ b/pkg/jsonlog/jsonlogbytes.go @@ -30,7 +30,7 @@ func (mj *JSONLogs) MarshalJSONBuf(buf *bytes.Buffer) error { ffjsonWriteJSONBytesAsString(buf, mj.Log) } if len(mj.Stream) != 0 { - if first == true { + if first { first = false } else { buf.WriteString(`,`) diff --git a/pkg/listeners/group_unix.go b/pkg/listeners/group_unix.go index c487079355426..e1d8774caeabd 100644 --- a/pkg/listeners/group_unix.go +++ b/pkg/listeners/group_unix.go @@ -23,7 +23,7 @@ func lookupGID(name string) (int, error) { if err != nil { return -1, errors.Wrapf(err, "error parsing groups for %s", name) } - if groups != nil && len(groups) > 0 { + if len(groups) > 0 { return groups[0].Gid, nil } gid, err := strconv.Atoi(name) diff --git a/pkg/mount/mount.go b/pkg/mount/mount.go index 66ac4bf4723ef..bb4cd887f7e24 100644 --- a/pkg/mount/mount.go +++ b/pkg/mount/mount.go @@ -46,10 +46,7 @@ func Mount(device, target, mType, options string) error { // flags.go for supported option flags. func ForceMount(device, target, mType, options string) error { flag, data := parseOptions(options) - if err := mount(device, target, mType, uintptr(flag), data); err != nil { - return err - } - return nil + return mount(device, target, mType, uintptr(flag), data) } // Unmount will unmount the target filesystem, so long as it is mounted. diff --git a/pkg/plugins/discovery_test.go b/pkg/plugins/discovery_test.go index 03f9d00319460..1a23faaead1e1 100644 --- a/pkg/plugins/discovery_test.go +++ b/pkg/plugins/discovery_test.go @@ -66,7 +66,7 @@ func TestFileSpecPlugin(t *testing.T) { t.Fatalf("Expected plugin addr `%s`, got %s\n", c.addr, p.Addr) } - if p.TLSConfig.InsecureSkipVerify != true { + if !p.TLSConfig.InsecureSkipVerify { t.Fatalf("Expected TLS verification to be skipped") } } diff --git a/pkg/plugins/discovery_unix_test.go b/pkg/plugins/discovery_unix_test.go index 3e2d506b9755b..1b232b7ade411 100644 --- a/pkg/plugins/discovery_unix_test.go +++ b/pkg/plugins/discovery_unix_test.go @@ -53,7 +53,7 @@ func TestLocalSocket(t *testing.T) { if p.Addr != addr { t.Fatalf("Expected plugin addr `%s`, got %s\n", addr, p.Addr) } - if p.TLSConfig.InsecureSkipVerify != true { + if !p.TLSConfig.InsecureSkipVerify { t.Fatalf("Expected TLS verification to be skipped") } l.Close() diff --git a/pkg/progress/progressreader_test.go b/pkg/progress/progressreader_test.go index b14d4015614aa..690e70596892d 100644 --- a/pkg/progress/progressreader_test.go +++ b/pkg/progress/progressreader_test.go @@ -14,7 +14,7 @@ func TestOutputOnPrematureClose(t *testing.T) { pr := NewProgressReader(reader, ChanOutput(progressChan), int64(len(content)), "Test", "Read") - part := make([]byte, 4, 4) + part := make([]byte, 4) _, err := io.ReadFull(pr, part) if err != nil { pr.Close() diff --git a/pkg/registrar/registrar.go b/pkg/registrar/registrar.go index 803b0d3c9b91a..df12db7eeb78d 100644 --- a/pkg/registrar/registrar.go +++ b/pkg/registrar/registrar.go @@ -100,9 +100,7 @@ func (r *Registrar) GetNames(key string) ([]string, error) { } ls := make([]string, 0, len(names)) - for _, n := range names { - ls = append(ls, n) - } + ls = append(ls, names...) return ls, nil }