rgw: remove refs to deprecated io/ioutil

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
This commit is contained in:
guoguangwu 2023-07-08 13:58:16 +08:00 committed by mergify[bot]
parent 8638693136
commit ce4031e218
3 changed files with 7 additions and 7 deletions

View File

@ -3,7 +3,7 @@ package admin
import (
"bytes"
"context"
"io/ioutil"
"io"
"net/http"
"net/url"
"time"
@ -98,12 +98,12 @@ func (api *API) call(ctx context.Context, httpMethod, path string, args url.Valu
defer resp.Body.Close()
// Decode HTTP response
decodedResponse, err := ioutil.ReadAll(resp.Body)
decodedResponse, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
resp.Body = ioutil.NopCloser(bytes.NewBuffer(decodedResponse))
resp.Body = io.NopCloser(bytes.NewBuffer(decodedResponse))
// Handle error in response
if resp.StatusCode >= 300 {

View File

@ -4,7 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"testing"
@ -57,7 +57,7 @@ func TestCreateSubuserMockAPI(t *testing.T) {
// mockClient is defined in user_test.go
func returnMockClientCreateSubuser() *mockClient {
r := ioutil.NopCloser(bytes.NewReader([]byte("")))
r := io.NopCloser(bytes.NewReader([]byte("")))
return &mockClient{
mockDo: func(req *http.Request) (*http.Response, error) {
if req.Method == http.MethodPut && req.URL.Path == "127.0.0.1/admin/user" {

View File

@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"testing"
@ -248,7 +248,7 @@ func TestGetUserMockAPI(t *testing.T) {
}
func returnMockClient() *mockClient {
r := ioutil.NopCloser(bytes.NewReader(fakeUserResponse))
r := io.NopCloser(bytes.NewReader(fakeUserResponse))
return &mockClient{
mockDo: func(req *http.Request) (*http.Response, error) {
if req.Method == http.MethodGet && req.URL.Path == "127.0.0.1/admin/user" {