golangci-lint: use v1.54, remove unnecessary byte/string conversions (#2438)

This commit is contained in:
mmetc 2023-08-25 16:22:10 +02:00 committed by GitHub
parent f2154e362b
commit c588be0842
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 11 additions and 10 deletions

View file

@ -61,7 +61,7 @@ jobs:
- name: golangci-lint - name: golangci-lint
uses: golangci/golangci-lint-action@v3 uses: golangci/golangci-lint-action@v3
with: with:
version: v1.51 version: v1.54
args: --issues-exit-code=1 --timeout 10m args: --issues-exit-code=1 --timeout 10m
only-new-issues: false only-new-issues: false
# the cache is already managed above, enabling it here # the cache is already managed above, enabling it here

View file

@ -145,7 +145,7 @@ jobs:
- name: golangci-lint - name: golangci-lint
uses: golangci/golangci-lint-action@v3 uses: golangci/golangci-lint-action@v3
with: with:
version: v1.51 version: v1.54
args: --issues-exit-code=1 --timeout 10m args: --issues-exit-code=1 --timeout 10m
only-new-issues: false only-new-issues: false
# the cache is already managed above, enabling it here # the cache is already managed above, enabling it here

View file

@ -105,6 +105,7 @@ linters:
# Recommended? (easy) # 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()) - 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. - 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. - 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. - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.
- promlinter # Check Prometheus metrics naming via promlint - promlinter # Check Prometheus metrics naming via promlint
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. - 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 - thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- wastedassign # wastedassign finds wasted assignment statements. - wastedassign # wastedassign finds wasted assignment statements.
- wrapcheck # Checks that errors returned from external packages are wrapped - 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) # Recommended? (requires some work)

View file

@ -370,7 +370,7 @@ func (cw *CloudwatchSource) LogStreamManager(in chan LogStreamTailConfig, outCha
} }
if cw.Config.StreamRegexp != nil { 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 { if err != nil {
cw.logger.Warningf("invalid regexp : %s", err) cw.logger.Warningf("invalid regexp : %s", err)
} else if !match { } else if !match {

View file

@ -392,14 +392,14 @@ func (d *DockerSource) EvalContainer(container dockerTypes.Container) (*Containe
} }
for _, cont := range d.compiledContainerID { 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 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 _, cont := range d.compiledContainerName {
for _, name := range container.Names { 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 return &ContainerConfig{ID: container.ID, Name: name, Labels: d.Config.Labels, Tty: d.getContainerTTY(container.ID)}, true
} }
} }

View file

@ -43,7 +43,7 @@ func downloadFile(url string, destPath string) error {
return err return err
} }
_, err = file.WriteString(string(body)) _, err = file.Write(body)
if err != nil { if err != nil {
return err return err
} }

View file

@ -76,7 +76,7 @@ func DownloadHubIdx(hub *csconfig.Hub) ([]byte, error) {
} }
defer file.Close() defer file.Close()
wsize, err := file.WriteString(string(body)) wsize, err := file.Write(body)
if err != nil { if err != nil {
return nil, fmt.Errorf("while writing hub index file: %w", err) 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) return target, fmt.Errorf("while opening file: %w", err)
} }
defer f.Close() defer f.Close()
_, err = f.WriteString(string(body)) _, err = f.Write(body)
if err != nil { if err != nil {
return target, fmt.Errorf("while writing file: %w", err) return target, fmt.Errorf("while writing file: %w", err)
} }

View file

@ -364,7 +364,7 @@ func TestSetFromYamlFile(t *testing.T) {
defer os.Remove(tmpfile.Name()) defer os.Remove(tmpfile.Name())
// write the config file // write the config file
_, err = tmpfile.Write([]byte("- experimental1")) _, err = tmpfile.WriteString("- experimental1")
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, tmpfile.Close()) require.NoError(t, tmpfile.Close())