mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 13:44:31 +00:00
Merge pull request #754 from gzliudan/use_replace_all
all: replace strings.Replace with string.ReplaceAll
This commit is contained in:
commit
b0ec10473d
6 changed files with 17 additions and 17 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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, "/")...)...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, "/")...)...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, "/")...)...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue