1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-06 00:03:32 +00:00

refactor: replace strings.Replace with strings.ReplaceAll

strings.ReplaceAll(s, old, new) is a wrapper function for
strings.Replace(s, old, new, -1). But strings.ReplaceAll is more
readable and removes the hardcoded -1.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun
2022-05-17 00:11:45 +08:00
committed by Nick Craig-Wood
parent b929a56f46
commit 4f0ddb60e7
20 changed files with 32 additions and 32 deletions

View File

@@ -230,7 +230,7 @@ func ConfigChoose(state string, name string, help string, n int, getItem func(i
// StatePush pushes a new values onto the front of the config string
func StatePush(state string, values ...string) string {
for i := range values {
values[i] = strings.Replace(values[i], ",", "", -1) // replace comma with unicode wide version
values[i] = strings.ReplaceAll(values[i], ",", "") // replace comma with unicode wide version
}
if state != "" {
values = append(values[:len(values):len(values)], state)
@@ -262,7 +262,7 @@ func StatePop(state string) (newState string, value string) {
return "", state
}
value, newState = state[:comma], state[comma+1:]
value = strings.Replace(value, "", ",", -1) // replace unicode wide comma with comma
value = strings.ReplaceAll(value, "", ",") // replace unicode wide comma with comma
return newState, value
}