Handle ioutil deprecations (#53526)

* replace ioutil.ReadFile -> os.ReadFile

* replace ioutil.ReadAll -> io.ReadAll

* replace ioutil.TempFile -> os.CreateTemp

* replace ioutil.NopCloser -> io.NopCloser

* replace ioutil.WriteFile -> os.WriteFile

* replace ioutil.TempDir -> os.MkdirTemp

* replace ioutil.Discard -> io.Discard
This commit is contained in:
Jo
2022-08-10 13:37:51 +00:00
committed by GitHub
parent 4926767737
commit 062d255124
140 changed files with 462 additions and 492 deletions

View File

@@ -3,7 +3,7 @@ package httpclient
import (
"errors"
"fmt"
"io/ioutil"
"io"
"strings"
"testing"
@@ -23,10 +23,10 @@ func TestMaxBytesReader(t *testing.T) {
}
for _, tc := range tcs {
t.Run(fmt.Sprintf("Test MaxBytesReader with limit: %d", tc.limit), func(t *testing.T) {
body := ioutil.NopCloser(strings.NewReader("dummy"))
body := io.NopCloser(strings.NewReader("dummy"))
readCloser := MaxBytesReader(body, tc.limit)
bodyBytes, err := ioutil.ReadAll(readCloser)
bodyBytes, err := io.ReadAll(readCloser)
if err != nil {
require.EqualError(t, tc.err, err.Error())
} else {