forked from cerc-io/plugeth
all: replace uses of ioutil with io and os (#24869)
This commit is contained in:
@@ -23,7 +23,6 @@ import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -580,7 +579,7 @@ func (n *handshakeTestNode) id() enode.ID {
|
||||
// hexFile reads the given file and decodes the hex data contained in it.
|
||||
// Whitespace and any lines beginning with the # character are ignored.
|
||||
func hexFile(file string) []byte {
|
||||
fileContent, err := ioutil.ReadFile(file)
|
||||
fileContent, err := os.ReadFile(file)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
+2
-3
@@ -21,7 +21,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
@@ -66,7 +65,7 @@ func (msg Msg) String() string {
|
||||
|
||||
// Discard reads any remaining payload data into a black hole.
|
||||
func (msg Msg) Discard() error {
|
||||
_, err := io.Copy(ioutil.Discard, msg.Payload)
|
||||
_, err := io.Copy(io.Discard, msg.Payload)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -245,7 +244,7 @@ func ExpectMsg(r MsgReader, code uint64, content interface{}) error {
|
||||
if int(msg.Size) != len(contentEnc) {
|
||||
return fmt.Errorf("message size mismatch: got %d, want %d", msg.Size, len(contentEnc))
|
||||
}
|
||||
actualContent, err := ioutil.ReadAll(msg.Payload)
|
||||
actualContent, err := io.ReadAll(msg.Payload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"sync/atomic"
|
||||
@@ -63,7 +63,7 @@ func main() {
|
||||
adapter = adapters.NewSimAdapter(services)
|
||||
|
||||
case "exec":
|
||||
tmpdir, err := ioutil.TempDir("", "p2p-example")
|
||||
tmpdir, err := os.MkdirTemp("", "p2p-example")
|
||||
if err != nil {
|
||||
log.Crit("error creating temp dir", "err", err)
|
||||
}
|
||||
@@ -156,7 +156,7 @@ func (p *pingPongService) Run(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
|
||||
errC <- err
|
||||
return
|
||||
}
|
||||
payload, err := ioutil.ReadAll(msg.Payload)
|
||||
payload, err := io.ReadAll(msg.Payload)
|
||||
if err != nil {
|
||||
errC <- err
|
||||
return
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"fmt"
|
||||
"html"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -112,7 +111,7 @@ func (c *Client) SubscribeNetwork(events chan *Event, opts SubscribeOpts) (event
|
||||
return nil, err
|
||||
}
|
||||
if res.StatusCode != http.StatusOK {
|
||||
response, _ := ioutil.ReadAll(res.Body)
|
||||
response, _ := io.ReadAll(res.Body)
|
||||
res.Body.Close()
|
||||
return nil, fmt.Errorf("unexpected HTTP status: %s: %s", res.Status, response)
|
||||
}
|
||||
@@ -252,7 +251,7 @@ func (c *Client) Send(method, path string, in, out interface{}) error {
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusOK && res.StatusCode != http.StatusCreated {
|
||||
response, _ := ioutil.ReadAll(res.Body)
|
||||
response, _ := io.ReadAll(res.Body)
|
||||
return fmt.Errorf("unexpected HTTP status: %s: %s", res.Status, response)
|
||||
}
|
||||
if out != nil {
|
||||
|
||||
Reference in New Issue
Block a user