all: replace strings.Replace with string.ReplaceAll (#24835)

pull/24837/head
s7v7nislands 3 years ago committed by GitHub
parent 86d5477079
commit 7caa2d8163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      accounts/abi/bind/bind.go
  2. 2
      accounts/abi/bind/template.go
  3. 2
      accounts/abi/type.go
  4. 4
      eth/downloader/downloader_test.go
  5. 2
      ethstats/ethstats.go
  6. 4
      internal/debug/api.go
  7. 4
      les/downloader/downloader_test.go
  8. 2
      metrics/prometheus/collector.go
  9. 2
      p2p/nat/natupnp_test.go
  10. 2
      rlp/decode_test.go

@ -179,7 +179,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
contracts[types[i]] = &tmplContract{
Type: capitalise(types[i]),
InputABI: strings.Replace(strippedABI, "\"", "\\\"", -1),
InputABI: strings.ReplaceAll(strippedABI, "\"", "\\\""),
InputBin: strings.TrimPrefix(strings.TrimSpace(bytecodes[i]), "0x"),
Constructor: evmABI.Constructor,
Calls: calls,

@ -161,7 +161,7 @@ var (
}
{{range $pattern, $name := .Libraries}}
{{decapitalise $name}}Addr, _, _, _ := Deploy{{capitalise $name}}(auth, backend)
{{$contract.Type}}Bin = strings.Replace({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:], -1)
{{$contract.Type}}Bin = strings.ReplaceAll({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:])
{{end}}
address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}})
if err != nil {

@ -201,7 +201,7 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
if internalType != "" && strings.HasPrefix(internalType, structPrefix) {
// Foo.Bar type definition is not allowed in golang,
// convert the format to FooBar
typ.TupleRawName = strings.Replace(internalType[len(structPrefix):], ".", "", -1)
typ.TupleRawName = strings.ReplaceAll(internalType[len(structPrefix):], ".", "")
}
case "function":

@ -1331,8 +1331,8 @@ func TestRemoteHeaderRequestSpan(t *testing.T) {
}
}
if failed {
res := strings.Replace(fmt.Sprint(data), " ", ",", -1)
exp := strings.Replace(fmt.Sprint(tt.expected), " ", ",", -1)
res := strings.ReplaceAll(fmt.Sprint(data), " ", ",")
exp := strings.ReplaceAll(fmt.Sprint(tt.expected), " ", ",")
t.Logf("got: %v\n", res)
t.Logf("exp: %v\n", exp)
t.Errorf("test %d: wrong values", i)

@ -366,7 +366,7 @@ func (s *Service) readLoop(conn *connWrapper) {
// If the network packet is a system ping, respond to it directly
var ping string
if err := json.Unmarshal(blob, &ping); err == nil && strings.HasPrefix(ping, "primus::ping::") {
if err := conn.WriteJSON(strings.Replace(ping, "ping", "pong", -1)); err != nil {
if err := conn.WriteJSON(strings.ReplaceAll(ping, "ping", "pong")); err != nil {
log.Warn("Failed to respond to system ping message", "err", err)
return
}

@ -209,8 +209,8 @@ func (*HandlerT) Stacks(filter *string) string {
// E.g. (eth || snap) && !p2p -> (eth in Value || snap in Value) && p2p not in Value
expanded = regexp.MustCompile(`[:/\.A-Za-z0-9_-]+`).ReplaceAllString(expanded, "`$0` in Value")
expanded = regexp.MustCompile("!(`[:/\\.A-Za-z0-9_-]+`)").ReplaceAllString(expanded, "$1 not")
expanded = strings.Replace(expanded, "||", "or", -1)
expanded = strings.Replace(expanded, "&&", "and", -1)
expanded = strings.ReplaceAll(expanded, "||", "or")
expanded = strings.ReplaceAll(expanded, "&&", "and")
log.Info("Expanded filter expression", "filter", *filter, "expanded", expanded)
expr, err := bexpr.CreateEvaluator(expanded)

@ -1577,8 +1577,8 @@ func TestRemoteHeaderRequestSpan(t *testing.T) {
}
}
if failed {
res := strings.Replace(fmt.Sprint(data), " ", ",", -1)
exp := strings.Replace(fmt.Sprint(tt.expected), " ", ",", -1)
res := strings.ReplaceAll(fmt.Sprint(data), " ", ",")
exp := strings.ReplaceAll(fmt.Sprint(tt.expected), " ", ",")
t.Logf("got: %v\n", res)
t.Logf("exp: %v\n", exp)
t.Errorf("test %d: wrong values", i)

@ -116,5 +116,5 @@ func (c *collector) writeSummaryPercentile(name, p string, value interface{}) {
}
func mutateKey(key string) string {
return strings.Replace(key, "/", "_", -1)
return strings.ReplaceAll(key, "/", "_")
}

@ -223,7 +223,7 @@ func (dev *fakeIGD) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func (dev *fakeIGD) replaceListenAddr(resp string) string {
return strings.Replace(resp, "{{listenAddr}}", dev.listener.Addr().String(), -1)
return strings.ReplaceAll(resp, "{{listenAddr}}", dev.listener.Addr().String())
}
func (dev *fakeIGD) listen() (err error) {

@ -1203,7 +1203,7 @@ func encodeTestSlice(n uint) []byte {
}
func unhex(str string) []byte {
b, err := hex.DecodeString(strings.Replace(str, " ", "", -1))
b, err := hex.DecodeString(strings.ReplaceAll(str, " ", ""))
if err != nil {
panic(fmt.Sprintf("invalid hex string: %q", str))
}

Loading…
Cancel
Save