mirror of https://github.com/docker/cli.git
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:
parent
8661552e7a
commit
606cbd60a1
|
@ -14,6 +14,7 @@ linters:
|
||||||
- megacheck
|
- megacheck
|
||||||
- misspell
|
- misspell
|
||||||
- nakedret
|
- nakedret
|
||||||
|
- predeclared
|
||||||
- revive
|
- revive
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- thelper
|
- thelper
|
||||||
|
|
|
@ -184,17 +184,17 @@ func stringSliceIndex(s, subs []string) int {
|
||||||
return -1
|
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.
|
// 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).
|
// 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) {
|
func StringSliceReplaceAt(s, find, replace []string, requireIndex int) ([]string, bool) {
|
||||||
idx := stringSliceIndex(s, old)
|
idx := stringSliceIndex(s, find)
|
||||||
if (requireIndex != -1 && requireIndex != idx) || idx == -1 {
|
if (requireIndex != -1 && requireIndex != idx) || idx == -1 {
|
||||||
return s, false
|
return s, false
|
||||||
}
|
}
|
||||||
out := append([]string{}, s[:idx]...)
|
out := append([]string{}, s[:idx]...)
|
||||||
out = append(out, new...)
|
out = append(out, replace...)
|
||||||
out = append(out, s[idx+len(old):]...)
|
out = append(out, s[idx+len(find):]...)
|
||||||
return out, true
|
return out, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue