build(linter): fix makezero linter issue (#965)

This commit is contained in:
Thomas Kohler 2023-06-20 19:07:24 +02:00
parent bc3d7d4194
commit a6d657118e
2 changed files with 5 additions and 4 deletions

View File

@ -32,7 +32,7 @@ linters:
# currently active linters: # currently active linters:
# #
#INFO [lintersdb] Active 35 linters: [asasalint asciicheck bidichk contextcheck decorder depguard durationcheck errcheck exportloopref #INFO [lintersdb] Active 35 linters: [asasalint asciicheck bidichk contextcheck decorder depguard durationcheck errcheck exportloopref
# gocheckcompilerdirectives gomoddirectives gomodguard goprintffuncname gosimple govet grouper ineffassign mirror musttag # gocheckcompilerdirectives gomoddirectives gomodguard goprintffuncname gosimple govet grouper ineffassign makezero mirror musttag
# nilerr nilnil nolintlint nosprintfhostport prealloc reassign revive staticcheck tagalign tenv testableexamples tparallel typecheck unused wastedassign] # nilerr nilnil nolintlint nosprintfhostport prealloc reassign revive staticcheck tagalign tenv testableexamples tparallel typecheck unused wastedassign]
enable-all: true enable-all: true
@ -74,7 +74,6 @@ linters:
- zerologlint # not needed (related to zerolog package) - zerologlint # not needed (related to zerolog package)
# important to have # important to have
- gofmt # important to prevent "format tsunami" ("gofmt -s -w" missed), disabled due to "https://github.com/golangci/golangci-lint-action/issues/535" - gofmt # important to prevent "format tsunami" ("gofmt -s -w" missed), disabled due to "https://github.com/golangci/golangci-lint-action/issues/535"
- makezero # very important (find/reduce bugs, e.g. in robot_work_test.go)
- nakedret # very useful together with "nonamedreturns" (reduce bugs) - nakedret # very useful together with "nonamedreturns" (reduce bugs)
- nonamedreturns # very useful (reduce bugs) - nonamedreturns # very useful (reduce bugs)
- unconvert # very useful (reduce bugs, simplify code) - unconvert # very useful (reduce bugs, simplify code)

View File

@ -94,8 +94,10 @@ func TestRobotAutomationFunctions(t *testing.T) {
func collectStringKeysFromWorkRegistry(rwr *RobotWorkRegistry) []string { func collectStringKeysFromWorkRegistry(rwr *RobotWorkRegistry) []string {
keys := make([]string, len(rwr.r)) keys := make([]string, len(rwr.r))
for k := range rwr.r { var idx int
keys = append(keys, k) for key := range rwr.r {
keys[idx] = key
idx++
} }
return keys return keys
} }