diff --git a/contrib/lock/storage/storage.go b/contrib/lock/storage/storage.go index e7d8c694c..7e39e38f6 100644 --- a/contrib/lock/storage/storage.go +++ b/contrib/lock/storage/storage.go @@ -96,8 +96,8 @@ func handler(w http.ResponseWriter, r *http.Request) { } func escape(s string) string { - escaped := strings.Replace(s, "\n", " ", -1) - escaped = strings.Replace(escaped, "\r", " ", -1) + escaped := strings.ReplaceAll(s, "\n", " ") + escaped = strings.ReplaceAll(escaped, "\r", " ") return escaped } diff --git a/pkg/cobrautl/help.go b/pkg/cobrautl/help.go index 44cdc9aa8..2f7e003df 100644 --- a/pkg/cobrautl/help.go +++ b/pkg/cobrautl/help.go @@ -99,7 +99,7 @@ GLOBAL OPTIONS: {{end}} `[1:] - commandUsageTemplate = template.Must(template.New("command_usage").Funcs(templFuncs).Parse(strings.Replace(commandUsage, "\\\n", "", -1))) + commandUsageTemplate = template.Must(template.New("command_usage").Funcs(templFuncs).Parse(strings.ReplaceAll(commandUsage, "\\\n", ""))) } func etcdFlagUsages(flagSet *pflag.FlagSet) string { diff --git a/pkg/flags/flag.go b/pkg/flags/flag.go index 76a51a890..5e60b72ad 100644 --- a/pkg/flags/flag.go +++ b/pkg/flags/flag.go @@ -66,7 +66,7 @@ func SetPflagsFromEnv(lg *zap.Logger, prefix string, fs *pflag.FlagSet) error { // FlagToEnv converts flag string to upper-case environment variable key string. func FlagToEnv(prefix, name string) string { - return prefix + "_" + strings.ToUpper(strings.Replace(name, "-", "_", -1)) + return prefix + "_" + strings.ToUpper(strings.ReplaceAll(name, "-", "_")) } func verifyEnv(lg *zap.Logger, prefix string, usedEnvKey, alreadySet map[string]bool) { diff --git a/tests/e2e/ctl_v3_grpc_test.go b/tests/e2e/ctl_v3_grpc_test.go index 94b7b3a57..3488c1912 100644 --- a/tests/e2e/ctl_v3_grpc_test.go +++ b/tests/e2e/ctl_v3_grpc_test.go @@ -106,7 +106,7 @@ func TestAuthority(t *testing.T) { } testutils.ExecuteWithTimeout(t, 5*time.Second, func() { - assertAuthority(t, strings.Replace(tc.expectAuthorityPattern, "${MEMBER_PORT}", "20000", -1), epc) + assertAuthority(t, strings.ReplaceAll(tc.expectAuthorityPattern, "${MEMBER_PORT}", "20000"), epc) }) }) @@ -119,7 +119,7 @@ func templateEndpoints(t *testing.T, pattern string, clus *e2e.EtcdProcessCluste var endpoints []string for i := 0; i < clus.Cfg.ClusterSize; i++ { ent := pattern - ent = strings.Replace(ent, "${MEMBER_PORT}", fmt.Sprintf("%d", e2e.EtcdProcessBasePort+i*5), -1) + ent = strings.ReplaceAll(ent, "${MEMBER_PORT}", fmt.Sprintf("%d", e2e.EtcdProcessBasePort+i*5)) endpoints = append(endpoints, ent) } return endpoints diff --git a/tests/functional/runner/help.go b/tests/functional/runner/help.go index 9bf9560a7..eb64b533f 100644 --- a/tests/functional/runner/help.go +++ b/tests/functional/runner/help.go @@ -101,7 +101,7 @@ GLOBAL OPTIONS: {{end}} `[1:] - commandUsageTemplate = template.Must(template.New("command_usage").Funcs(templFuncs).Parse(strings.Replace(commandUsage, "\\\n", "", -1))) + commandUsageTemplate = template.Must(template.New("command_usage").Funcs(templFuncs).Parse(strings.ReplaceAll(commandUsage, "\\\n", ""))) } func etcdFlagUsages(flagSet *pflag.FlagSet) string { diff --git a/tests/integration/grpc_test.go b/tests/integration/grpc_test.go index 2fa1afeb9..47519bfb9 100644 --- a/tests/integration/grpc_test.go +++ b/tests/integration/grpc_test.go @@ -146,8 +146,8 @@ func templateEndpoints(t *testing.T, pattern string, clus *integration.Cluster) var endpoints []string for _, m := range clus.Members { ent := pattern - ent = strings.Replace(ent, "${MEMBER_PORT}", m.GrpcPortNumber(), -1) - ent = strings.Replace(ent, "${MEMBER_NAME}", m.Name, -1) + ent = strings.ReplaceAll(ent, "${MEMBER_PORT}", m.GrpcPortNumber()) + ent = strings.ReplaceAll(ent, "${MEMBER_NAME}", m.Name) endpoints = append(endpoints, ent) } return endpoints @@ -156,8 +156,8 @@ func templateEndpoints(t *testing.T, pattern string, clus *integration.Cluster) func templateAuthority(t *testing.T, pattern string, m *integration.Member) string { t.Helper() authority := pattern - authority = strings.Replace(authority, "${MEMBER_PORT}", m.GrpcPortNumber(), -1) - authority = strings.Replace(authority, "${MEMBER_NAME}", m.Name, -1) + authority = strings.ReplaceAll(authority, "${MEMBER_PORT}", m.GrpcPortNumber()) + authority = strings.ReplaceAll(authority, "${MEMBER_NAME}", m.Name) return authority } diff --git a/tests/linearizability/linearizability_test.go b/tests/linearizability/linearizability_test.go index f3aa926ef..9e7302258 100644 --- a/tests/linearizability/linearizability_test.go +++ b/tests/linearizability/linearizability_test.go @@ -219,7 +219,7 @@ func persistMemberDataDir(t *testing.T, clus *e2e.EtcdProcessCluster, path strin } func testResultsDirectory(t *testing.T) (string, error) { - path, err := filepath.Abs(filepath.Join(resultsDirectory, strings.Replace(t.Name(), "/", "_", -1))) + path, err := filepath.Abs(filepath.Join(resultsDirectory, strings.ReplaceAll(t.Name(), "/", "_"))) if err != nil { return path, err }