all: replace uses of ioutil with io and os (#24869)

This commit is contained in:
Håvard Anda Estensen
2022-05-16 11:59:35 +02:00
committed by GitHub
parent 330e53fbb9
commit 07508ac0e9
97 changed files with 203 additions and 257 deletions
+3 -3
View File
@@ -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
+2 -3
View File
@@ -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 {