golangci-lint: enable predeclared linter

cli/command/utils.go:190:35: param new has same name as predeclared identifier (predeclared)
    func StringSliceReplaceAt(s, old, new []string, requireIndex int) ([]string, bool) {
                                      ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-11-20 11:15:36 +01:00
parent 8661552e7a
commit 606cbd60a1
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 6 additions and 5 deletions

View File

@ -14,6 +14,7 @@ linters:
- megacheck
- misspell
- nakedret
- predeclared
- revive
- staticcheck
- thelper

View File

@ -184,17 +184,17 @@ func stringSliceIndex(s, subs []string) int {
return -1
}
// StringSliceReplaceAt replaces the sub-slice old, with the sub-slice new, in the string
// StringSliceReplaceAt replaces the sub-slice find, with the sub-slice replace, in the string
// slice s, returning a new slice and a boolean indicating if the replacement happened.
// requireIdx is the index at which old needs to be found at (or -1 to disregard that).
func StringSliceReplaceAt(s, old, new []string, requireIndex int) ([]string, bool) {
idx := stringSliceIndex(s, old)
func StringSliceReplaceAt(s, find, replace []string, requireIndex int) ([]string, bool) {
idx := stringSliceIndex(s, find)
if (requireIndex != -1 && requireIndex != idx) || idx == -1 {
return s, false
}
out := append([]string{}, s[:idx]...)
out = append(out, new...)
out = append(out, s[idx+len(old):]...)
out = append(out, replace...)
out = append(out, s[idx+len(find):]...)
return out, true
}