all: replace strings.Replace with string.ReplaceAll (#24835)
This commit is contained in:
parent
86d5477079
commit
7caa2d8163
@ -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…
Reference in New Issue
Block a user