Skip to content

Commit 606cbd6

Browse files
committed
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>
1 parent 8661552 commit 606cbd6

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ linters:
1414
- megacheck
1515
- misspell
1616
- nakedret
17+
- predeclared
1718
- revive
1819
- staticcheck
1920
- thelper

cli/command/utils.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,17 @@ func stringSliceIndex(s, subs []string) int {
184184
return -1
185185
}
186186

187-
// StringSliceReplaceAt replaces the sub-slice old, with the sub-slice new, in the string
187+
// StringSliceReplaceAt replaces the sub-slice find, with the sub-slice replace, in the string
188188
// slice s, returning a new slice and a boolean indicating if the replacement happened.
189189
// requireIdx is the index at which old needs to be found at (or -1 to disregard that).
190-
func StringSliceReplaceAt(s, old, new []string, requireIndex int) ([]string, bool) {
191-
idx := stringSliceIndex(s, old)
190+
func StringSliceReplaceAt(s, find, replace []string, requireIndex int) ([]string, bool) {
191+
idx := stringSliceIndex(s, find)
192192
if (requireIndex != -1 && requireIndex != idx) || idx == -1 {
193193
return s, false
194194
}
195195
out := append([]string{}, s[:idx]...)
196-
out = append(out, new...)
197-
out = append(out, s[idx+len(old):]...)
196+
out = append(out, replace...)
197+
out = append(out, s[idx+len(find):]...)
198198
return out, true
199199
}
200200

0 commit comments

Comments
 (0)