From a321456c785eb2e33bdb4d83a9f0798602a4b39d Mon Sep 17 00:00:00 2001 From: Ruslan Efanov Date: Fri, 28 Oct 2022 10:05:11 +0300 Subject: [PATCH] fix undefined package error --- v1/errors_test.go | 6 +++--- v1/helpers.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/v1/errors_test.go b/v1/errors_test.go index cf3ddcc..2c4bb2f 100644 --- a/v1/errors_test.go +++ b/v1/errors_test.go @@ -4,7 +4,7 @@ import ( "bytes" "errors" "fmt" - "io" + "io/ioutil" "net/http" "net/url" "testing" @@ -39,7 +39,7 @@ func TestNewApiClientError(t *testing.T) { func TestNewServerError(t *testing.T) { body := []byte(`{"errors" : ["Something went wrong"]}`) response := new(http.Response) - response.Body = io.NopCloser(bytes.NewReader(body)) + response.Body = ioutil.NopCloser(bytes.NewReader(body)) serverErr := NewServerError(response) assert.IsType(t, new(HTTPClientError), serverErr) @@ -54,7 +54,7 @@ func TestNewServerError(t *testing.T) { body = []byte(`{"invalid_json"`) response = new(http.Response) - response.Body = io.NopCloser(bytes.NewReader(body)) + response.Body = ioutil.NopCloser(bytes.NewReader(body)) serverErr = NewServerError(response) assert.IsType(t, new(HTTPClientError), serverErr) diff --git a/v1/helpers.go b/v1/helpers.go index 67ea32c..24fec0e 100644 --- a/v1/helpers.go +++ b/v1/helpers.go @@ -2,6 +2,7 @@ package v1 import ( "io" + "io/ioutil" "net/http" ) @@ -11,7 +12,7 @@ func buildLimitedRawResponse(resp *http.Response) ([]byte, error) { defer resp.Body.Close() limitReader := io.LimitReader(resp.Body, MB) - body, err := io.ReadAll(limitReader) + body, err := ioutil.ReadAll(limitReader) if err != nil { return body, err