remove deprecated of package io/ioutil (#3395)
This commit is contained in:
@ -9,7 +9,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -656,12 +655,12 @@ func TestBindingFormFilesMultipart(t *testing.T) {
|
||||
// file from os
|
||||
f, _ := os.Open("form.go")
|
||||
defer f.Close()
|
||||
fileActual, _ := ioutil.ReadAll(f)
|
||||
fileActual, _ := io.ReadAll(f)
|
||||
|
||||
// file from multipart
|
||||
mf, _ := obj.File.Open()
|
||||
defer mf.Close()
|
||||
fileExpect, _ := ioutil.ReadAll(mf)
|
||||
fileExpect, _ := io.ReadAll(mf)
|
||||
|
||||
assert.Equal(t, FormMultipart.Name(), "multipart/form-data")
|
||||
assert.Equal(t, obj.Foo, "bar")
|
||||
@ -1347,13 +1346,13 @@ func testProtoBodyBindingFail(t *testing.T, b Binding, name, path, badPath, body
|
||||
obj := protoexample.Test{}
|
||||
req := requestWithBody("POST", path, body)
|
||||
|
||||
req.Body = ioutil.NopCloser(&hook{})
|
||||
req.Body = io.NopCloser(&hook{})
|
||||
req.Header.Add("Content-Type", MIMEPROTOBUF)
|
||||
err := b.Bind(req, &obj)
|
||||
assert.Error(t, err)
|
||||
|
||||
invalidobj := FooStruct{}
|
||||
req.Body = ioutil.NopCloser(strings.NewReader(`{"msg":"hello"}`))
|
||||
req.Body = io.NopCloser(strings.NewReader(`{"msg":"hello"}`))
|
||||
req.Header.Add("Content-Type", MIMEPROTOBUF)
|
||||
err = b.Bind(req, &invalidobj)
|
||||
assert.Error(t, err)
|
||||
|
@ -6,7 +6,7 @@ package binding
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"testing"
|
||||
@ -129,7 +129,7 @@ func assertMultipartFileHeader(t *testing.T, fh *multipart.FileHeader, file test
|
||||
fl, err := fh.Open()
|
||||
assert.NoError(t, err)
|
||||
|
||||
body, err := ioutil.ReadAll(fl)
|
||||
body, err := io.ReadAll(fl)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, string(file.Content), string(body))
|
||||
|
||||
|
@ -6,7 +6,7 @@ package binding
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
@ -19,7 +19,7 @@ func (protobufBinding) Name() string {
|
||||
}
|
||||
|
||||
func (b protobufBinding) Bind(req *http.Request, obj any) error {
|
||||
buf, err := ioutil.ReadAll(req.Body)
|
||||
buf, err := io.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user