diff --git a/.github/workflows/go-tests-windows.yml b/.github/workflows/go-tests-windows.yml index 772c574ab..276a0210b 100644 --- a/.github/workflows/go-tests-windows.yml +++ b/.github/workflows/go-tests-windows.yml @@ -61,7 +61,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.51 + version: v1.54 args: --issues-exit-code=1 --timeout 10m only-new-issues: false # the cache is already managed above, enabling it here diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index 2dff8af21..5942748d6 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -145,7 +145,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.51 + version: v1.54 args: --issues-exit-code=1 --timeout 10m only-new-issues: false # the cache is already managed above, enabling it here diff --git a/.golangci.yml b/.golangci.yml index faa67c4bb..0ba65ee05 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -105,6 +105,7 @@ linters: # Recommended? (easy) # + - depguard # Go linter that checks if package imports are in a list of acceptable packages - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) - errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occations, where the check for the returned error can be omitted. - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. @@ -121,10 +122,10 @@ linters: - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - promlinter # Check Prometheus metrics naming via promlint - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. + - tagalign # check that struct tags are well aligned [fast: true, auto-fix: true] - thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers - wastedassign # wastedassign finds wasted assignment statements. - wrapcheck # Checks that errors returned from external packages are wrapped - - depguard # Go linter that checks if package imports are in a list of acceptable packages # # Recommended? (requires some work) diff --git a/pkg/acquisition/modules/cloudwatch/cloudwatch.go b/pkg/acquisition/modules/cloudwatch/cloudwatch.go index 48bbe4217..89887bef0 100644 --- a/pkg/acquisition/modules/cloudwatch/cloudwatch.go +++ b/pkg/acquisition/modules/cloudwatch/cloudwatch.go @@ -370,7 +370,7 @@ func (cw *CloudwatchSource) LogStreamManager(in chan LogStreamTailConfig, outCha } if cw.Config.StreamRegexp != nil { - match, err := regexp.Match(*cw.Config.StreamRegexp, []byte(newStream.StreamName)) + match, err := regexp.MatchString(*cw.Config.StreamRegexp, newStream.StreamName) if err != nil { cw.logger.Warningf("invalid regexp : %s", err) } else if !match { diff --git a/pkg/acquisition/modules/docker/docker.go b/pkg/acquisition/modules/docker/docker.go index 929626974..60f1100b3 100644 --- a/pkg/acquisition/modules/docker/docker.go +++ b/pkg/acquisition/modules/docker/docker.go @@ -392,14 +392,14 @@ func (d *DockerSource) EvalContainer(container dockerTypes.Container) (*Containe } for _, cont := range d.compiledContainerID { - if matched := cont.Match([]byte(container.ID)); matched { + if matched := cont.MatchString(container.ID); matched { return &ContainerConfig{ID: container.ID, Name: container.Names[0], Labels: d.Config.Labels, Tty: d.getContainerTTY(container.ID)}, true } } for _, cont := range d.compiledContainerName { for _, name := range container.Names { - if matched := cont.Match([]byte(name)); matched { + if matched := cont.MatchString(name); matched { return &ContainerConfig{ID: container.ID, Name: name, Labels: d.Config.Labels, Tty: d.getContainerTTY(container.ID)}, true } } diff --git a/pkg/cwhub/dataset.go b/pkg/cwhub/dataset.go index a6488751b..3bfcddee8 100644 --- a/pkg/cwhub/dataset.go +++ b/pkg/cwhub/dataset.go @@ -43,7 +43,7 @@ func downloadFile(url string, destPath string) error { return err } - _, err = file.WriteString(string(body)) + _, err = file.Write(body) if err != nil { return err } diff --git a/pkg/cwhub/download.go b/pkg/cwhub/download.go index 491e31dab..06596fe14 100644 --- a/pkg/cwhub/download.go +++ b/pkg/cwhub/download.go @@ -76,7 +76,7 @@ func DownloadHubIdx(hub *csconfig.Hub) ([]byte, error) { } defer file.Close() - wsize, err := file.WriteString(string(body)) + wsize, err := file.Write(body) if err != nil { return nil, fmt.Errorf("while writing hub index file: %w", err) } @@ -216,7 +216,7 @@ func DownloadItem(hub *csconfig.Hub, target Item, overwrite bool) (Item, error) return target, fmt.Errorf("while opening file: %w", err) } defer f.Close() - _, err = f.WriteString(string(body)) + _, err = f.Write(body) if err != nil { return target, fmt.Errorf("while writing file: %w", err) } diff --git a/pkg/fflag/features_test.go b/pkg/fflag/features_test.go index dc19c101b..57745b3c3 100644 --- a/pkg/fflag/features_test.go +++ b/pkg/fflag/features_test.go @@ -364,7 +364,7 @@ func TestSetFromYamlFile(t *testing.T) { defer os.Remove(tmpfile.Name()) // write the config file - _, err = tmpfile.Write([]byte("- experimental1")) + _, err = tmpfile.WriteString("- experimental1") require.NoError(t, err) require.NoError(t, tmpfile.Close())