From d9e9e069dd03131036c38ac499b1348fbbc81966 Mon Sep 17 00:00:00 2001
From: Daniel Liu <liudaniel@qq.com>
Date: Wed, 4 Dec 2024 10:52:46 +0800
Subject: [PATCH] all: replace strings.Replace with string.ReplaceAll (#24835)

---
 accounts/abi/bind/bind.go              |  2 +-
 cmd/faucet/website.go                  | 10 +++++-----
 eth/tracers/internal/tracers/assets.go | 10 +++++-----
 ethstats/ethstats.go                   |  2 +-
 internal/jsre/deps/bindata.go          |  8 ++++----
 p2p/nat/natupnp_test.go                |  2 +-
 6 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/accounts/abi/bind/bind.go b/accounts/abi/bind/bind.go
index 44de4cc74aeda..79d05afb445d8 100644
--- a/accounts/abi/bind/bind.go
+++ b/accounts/abi/bind/bind.go
@@ -117,7 +117,7 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La
 		}
 		contracts[types[i]] = &tmplContract{
 			Type:        capitalise(types[i]),
-			InputABI:    strings.Replace(strippedABI, "\"", "\\\"", -1),
+			InputABI:    strings.ReplaceAll(strippedABI, "\"", "\\\""),
 			InputBin:    strings.TrimSpace(bytecodes[i]),
 			Constructor: evmABI.Constructor,
 			Calls:       calls,
diff --git a/cmd/faucet/website.go b/cmd/faucet/website.go
index 2b204731167a6..0404f38e9a269 100644
--- a/cmd/faucet/website.go
+++ b/cmd/faucet/website.go
@@ -92,7 +92,7 @@ func faucetHtml() (*asset, error) {
 // It returns an error if the asset could not be found or
 // could not be loaded.
 func Asset(name string) ([]byte, error) {
-	canonicalName := strings.Replace(name, "\\", "/", -1)
+	canonicalName := strings.ReplaceAll(name, "\\", "/")
 	if f, ok := _bindata[canonicalName]; ok {
 		a, err := f()
 		if err != nil {
@@ -130,7 +130,7 @@ func MustAssetString(name string) string {
 // It returns an error if the asset could not be found or
 // could not be loaded.
 func AssetInfo(name string) (os.FileInfo, error) {
-	canonicalName := strings.Replace(name, "\\", "/", -1)
+	canonicalName := strings.ReplaceAll(name, "\\", "/")
 	if f, ok := _bindata[canonicalName]; ok {
 		a, err := f()
 		if err != nil {
@@ -144,7 +144,7 @@ func AssetInfo(name string) (os.FileInfo, error) {
 // AssetDigest returns the digest of the file with the given name. It returns an
 // error if the asset could not be found or the digest could not be loaded.
 func AssetDigest(name string) ([sha256.Size]byte, error) {
-	canonicalName := strings.Replace(name, "\\", "/", -1)
+	canonicalName := strings.ReplaceAll(name, "\\", "/")
 	if f, ok := _bindata[canonicalName]; ok {
 		a, err := f()
 		if err != nil {
@@ -203,7 +203,7 @@ const AssetDebug = false
 func AssetDir(name string) ([]string, error) {
 	node := _bintree
 	if len(name) != 0 {
-		canonicalName := strings.Replace(name, "\\", "/", -1)
+		canonicalName := strings.ReplaceAll(name, "\\", "/")
 		pathList := strings.Split(canonicalName, "/")
 		for _, p := range pathList {
 			node = node.Children[p]
@@ -270,6 +270,6 @@ func RestoreAssets(dir, name string) error {
 }
 
 func _filePath(dir, name string) string {
-	canonicalName := strings.Replace(name, "\\", "/", -1)
+	canonicalName := strings.ReplaceAll(name, "\\", "/")
 	return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...)
 }
diff --git a/eth/tracers/internal/tracers/assets.go b/eth/tracers/internal/tracers/assets.go
index 1f0398e02407c..da9c9832439fe 100644
--- a/eth/tracers/internal/tracers/assets.go
+++ b/eth/tracers/internal/tracers/assets.go
@@ -302,7 +302,7 @@ func unigram_tracerJs() (*asset, error) {
 // It returns an error if the asset could not be found or
 // could not be loaded.
 func Asset(name string) ([]byte, error) {
-	canonicalName := strings.Replace(name, "\\", "/", -1)
+	canonicalName := strings.ReplaceAll(name, "\\", "/")
 	if f, ok := _bindata[canonicalName]; ok {
 		a, err := f()
 		if err != nil {
@@ -340,7 +340,7 @@ func MustAssetString(name string) string {
 // It returns an error if the asset could not be found or
 // could not be loaded.
 func AssetInfo(name string) (os.FileInfo, error) {
-	canonicalName := strings.Replace(name, "\\", "/", -1)
+	canonicalName := strings.ReplaceAll(name, "\\", "/")
 	if f, ok := _bindata[canonicalName]; ok {
 		a, err := f()
 		if err != nil {
@@ -354,7 +354,7 @@ func AssetInfo(name string) (os.FileInfo, error) {
 // AssetDigest returns the digest of the file with the given name. It returns an
 // error if the asset could not be found or the digest could not be loaded.
 func AssetDigest(name string) ([sha256.Size]byte, error) {
-	canonicalName := strings.Replace(name, "\\", "/", -1)
+	canonicalName := strings.ReplaceAll(name, "\\", "/")
 	if f, ok := _bindata[canonicalName]; ok {
 		a, err := f()
 		if err != nil {
@@ -421,7 +421,7 @@ const AssetDebug = false
 func AssetDir(name string) ([]string, error) {
 	node := _bintree
 	if len(name) != 0 {
-		canonicalName := strings.Replace(name, "\\", "/", -1)
+		canonicalName := strings.ReplaceAll(name, "\\", "/")
 		pathList := strings.Split(canonicalName, "/")
 		for _, p := range pathList {
 			node = node.Children[p]
@@ -498,6 +498,6 @@ func RestoreAssets(dir, name string) error {
 }
 
 func _filePath(dir, name string) string {
-	canonicalName := strings.Replace(name, "\\", "/", -1)
+	canonicalName := strings.ReplaceAll(name, "\\", "/")
 	return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...)
 }
diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go
index d4872e6362e51..4510478bb0e51 100644
--- a/ethstats/ethstats.go
+++ b/ethstats/ethstats.go
@@ -367,7 +367,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
 			}
diff --git a/internal/jsre/deps/bindata.go b/internal/jsre/deps/bindata.go
index bae4115a6c00d..89e83b60b5a95 100644
--- a/internal/jsre/deps/bindata.go
+++ b/internal/jsre/deps/bindata.go
@@ -122,7 +122,7 @@ func web3Js() (*asset, error) {
 // It returns an error if the asset could not be found or
 // could not be loaded.
 func Asset(name string) ([]byte, error) {
-	cannonicalName := strings.Replace(name, "\\", "/", -1)
+	cannonicalName := strings.ReplaceAll(name, "\\", "/")
 	if f, ok := _bindata[cannonicalName]; ok {
 		a, err := f()
 		if err != nil {
@@ -148,7 +148,7 @@ func MustAsset(name string) []byte {
 // It returns an error if the asset could not be found or
 // could not be loaded.
 func AssetInfo(name string) (os.FileInfo, error) {
-	cannonicalName := strings.Replace(name, "\\", "/", -1)
+	cannonicalName := strings.ReplaceAll(name, "\\", "/")
 	if f, ok := _bindata[cannonicalName]; ok {
 		a, err := f()
 		if err != nil {
@@ -192,7 +192,7 @@ var _bindata = map[string]func() (*asset, error){
 func AssetDir(name string) ([]string, error) {
 	node := _bintree
 	if len(name) != 0 {
-		cannonicalName := strings.Replace(name, "\\", "/", -1)
+		cannonicalName := strings.ReplaceAll(name, "\\", "/")
 		pathList := strings.Split(cannonicalName, "/")
 		for _, p := range pathList {
 			node = node.Children[p]
@@ -264,6 +264,6 @@ func RestoreAssets(dir, name string) error {
 }
 
 func _filePath(dir, name string) string {
-	cannonicalName := strings.Replace(name, "\\", "/", -1)
+	cannonicalName := strings.ReplaceAll(name, "\\", "/")
 	return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
 }
diff --git a/p2p/nat/natupnp_test.go b/p2p/nat/natupnp_test.go
index 79f6d25ae87f4..258bd4fdb9374 100644
--- a/p2p/nat/natupnp_test.go
+++ b/p2p/nat/natupnp_test.go
@@ -218,7 +218,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) {