golangci-lint: use v1.54, remove unnecessary byte/string conversions (#2438)
This commit is contained in:
parent
f2154e362b
commit
c588be0842
8 changed files with 11 additions and 10 deletions
2
.github/workflows/go-tests-windows.yml
vendored
2
.github/workflows/go-tests-windows.yml
vendored
|
@ -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
|
||||
|
|
2
.github/workflows/go-tests.yml
vendored
2
.github/workflows/go-tests.yml
vendored
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
Loading…
Reference in a new issue