Skip to content

Commit 7caa2d8

Browse files
authored
all: replace strings.Replace with string.ReplaceAll (#24835)
1 parent 86d5477 commit 7caa2d8

File tree

10 files changed

+13
-13
lines changed

10 files changed

+13
-13
lines changed

accounts/abi/bind/bind.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
179179

180180
contracts[types[i]] = &tmplContract{
181181
Type: capitalise(types[i]),
182-
InputABI: strings.Replace(strippedABI, "\"", "\\\"", -1),
182+
InputABI: strings.ReplaceAll(strippedABI, "\"", "\\\""),
183183
InputBin: strings.TrimPrefix(strings.TrimSpace(bytecodes[i]), "0x"),
184184
Constructor: evmABI.Constructor,
185185
Calls: calls,

accounts/abi/bind/template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ var (
161161
}
162162
{{range $pattern, $name := .Libraries}}
163163
{{decapitalise $name}}Addr, _, _, _ := Deploy{{capitalise $name}}(auth, backend)
164-
{{$contract.Type}}Bin = strings.Replace({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:], -1)
164+
{{$contract.Type}}Bin = strings.ReplaceAll({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:])
165165
{{end}}
166166
address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}})
167167
if err != nil {

accounts/abi/type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
201201
if internalType != "" && strings.HasPrefix(internalType, structPrefix) {
202202
// Foo.Bar type definition is not allowed in golang,
203203
// convert the format to FooBar
204-
typ.TupleRawName = strings.Replace(internalType[len(structPrefix):], ".", "", -1)
204+
typ.TupleRawName = strings.ReplaceAll(internalType[len(structPrefix):], ".", "")
205205
}
206206

207207
case "function":

eth/downloader/downloader_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,8 +1331,8 @@ func TestRemoteHeaderRequestSpan(t *testing.T) {
13311331
}
13321332
}
13331333
if failed {
1334-
res := strings.Replace(fmt.Sprint(data), " ", ",", -1)
1335-
exp := strings.Replace(fmt.Sprint(tt.expected), " ", ",", -1)
1334+
res := strings.ReplaceAll(fmt.Sprint(data), " ", ",")
1335+
exp := strings.ReplaceAll(fmt.Sprint(tt.expected), " ", ",")
13361336
t.Logf("got: %v\n", res)
13371337
t.Logf("exp: %v\n", exp)
13381338
t.Errorf("test %d: wrong values", i)

ethstats/ethstats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ func (s *Service) readLoop(conn *connWrapper) {
366366
// If the network packet is a system ping, respond to it directly
367367
var ping string
368368
if err := json.Unmarshal(blob, &ping); err == nil && strings.HasPrefix(ping, "primus::ping::") {
369-
if err := conn.WriteJSON(strings.Replace(ping, "ping", "pong", -1)); err != nil {
369+
if err := conn.WriteJSON(strings.ReplaceAll(ping, "ping", "pong")); err != nil {
370370
log.Warn("Failed to respond to system ping message", "err", err)
371371
return
372372
}

internal/debug/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ func (*HandlerT) Stacks(filter *string) string {
209209
// E.g. (eth || snap) && !p2p -> (eth in Value || snap in Value) && p2p not in Value
210210
expanded = regexp.MustCompile(`[:/\.A-Za-z0-9_-]+`).ReplaceAllString(expanded, "`$0` in Value")
211211
expanded = regexp.MustCompile("!(`[:/\\.A-Za-z0-9_-]+`)").ReplaceAllString(expanded, "$1 not")
212-
expanded = strings.Replace(expanded, "||", "or", -1)
213-
expanded = strings.Replace(expanded, "&&", "and", -1)
212+
expanded = strings.ReplaceAll(expanded, "||", "or")
213+
expanded = strings.ReplaceAll(expanded, "&&", "and")
214214
log.Info("Expanded filter expression", "filter", *filter, "expanded", expanded)
215215

216216
expr, err := bexpr.CreateEvaluator(expanded)

les/downloader/downloader_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,8 +1577,8 @@ func TestRemoteHeaderRequestSpan(t *testing.T) {
15771577
}
15781578
}
15791579
if failed {
1580-
res := strings.Replace(fmt.Sprint(data), " ", ",", -1)
1581-
exp := strings.Replace(fmt.Sprint(tt.expected), " ", ",", -1)
1580+
res := strings.ReplaceAll(fmt.Sprint(data), " ", ",")
1581+
exp := strings.ReplaceAll(fmt.Sprint(tt.expected), " ", ",")
15821582
t.Logf("got: %v\n", res)
15831583
t.Logf("exp: %v\n", exp)
15841584
t.Errorf("test %d: wrong values", i)

metrics/prometheus/collector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,5 @@ func (c *collector) writeSummaryPercentile(name, p string, value interface{}) {
116116
}
117117

118118
func mutateKey(key string) string {
119-
return strings.Replace(key, "/", "_", -1)
119+
return strings.ReplaceAll(key, "/", "_")
120120
}

p2p/nat/natupnp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func (dev *fakeIGD) ServeHTTP(w http.ResponseWriter, r *http.Request) {
223223
}
224224

225225
func (dev *fakeIGD) replaceListenAddr(resp string) string {
226-
return strings.Replace(resp, "{{listenAddr}}", dev.listener.Addr().String(), -1)
226+
return strings.ReplaceAll(resp, "{{listenAddr}}", dev.listener.Addr().String())
227227
}
228228

229229
func (dev *fakeIGD) listen() (err error) {

rlp/decode_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ func encodeTestSlice(n uint) []byte {
12031203
}
12041204

12051205
func unhex(str string) []byte {
1206-
b, err := hex.DecodeString(strings.Replace(str, " ", "", -1))
1206+
b, err := hex.DecodeString(strings.ReplaceAll(str, " ", ""))
12071207
if err != nil {
12081208
panic(fmt.Sprintf("invalid hex string: %q", str))
12091209
}

0 commit comments

Comments
 (0)