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
+2 -3
View File
@@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"mime"
"net/http"
"net/url"
@@ -176,12 +175,12 @@ func (hc *httpConn) doRequest(ctx context.Context, msg interface{}) (io.ReadClos
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, "POST", hc.url, ioutil.NopCloser(bytes.NewReader(body)))
req, err := http.NewRequestWithContext(ctx, "POST", hc.url, io.NopCloser(bytes.NewReader(body)))
if err != nil {
return nil, err
}
req.ContentLength = int64(len(body))
req.GetBody = func() (io.ReadCloser, error) { return ioutil.NopCloser(bytes.NewReader(body)), nil }
req.GetBody = func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(body)), nil }
// set headers
hc.mu.Lock()
+2 -1
View File
@@ -22,6 +22,7 @@ import (
"io"
"io/ioutil"
"net"
"os"
"path/filepath"
"strings"
"testing"
@@ -70,7 +71,7 @@ func TestServer(t *testing.T) {
func runTestScript(t *testing.T, file string) {
server := newTestServer()
content, err := ioutil.ReadFile(file)
content, err := os.ReadFile(file)
if err != nil {
t.Fatal(err)
}