migrate away from deprecated ioutil APIs (#7175)

Co-authored-by: Callum Waters <cmwaters19@gmail.com>
Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
This commit is contained in:
Sharad Chand
2021-10-28 10:34:07 -07:00
committed by GitHub
co-authored by Callum Waters M. J. Fromberger
parent 6108d0a9b5
commit 8441b3715a
58 changed files with 158 additions and 192 deletions
+3 -3
View File
@@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"net/url"
@@ -219,7 +219,7 @@ func (c *Client) Call(
defer httpResponse.Body.Close()
responseBytes, err := ioutil.ReadAll(httpResponse.Body)
responseBytes, err := io.ReadAll(httpResponse.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}
@@ -267,7 +267,7 @@ func (c *Client) sendBatch(ctx context.Context, requests []*jsonRPCBufferedReque
defer httpResponse.Body.Close()
responseBytes, err := ioutil.ReadAll(httpResponse.Body)
responseBytes, err := io.ReadAll(httpResponse.Body)
if err != nil {
return nil, fmt.Errorf("read response body: %w", err)
}
+2 -2
View File
@@ -1,7 +1,7 @@
package client
import (
"io/ioutil"
"io"
"log"
"net/http"
"net/http/httptest"
@@ -21,7 +21,7 @@ func TestHTTPClientMakeHTTPDialer(t *testing.T) {
defer tsTLS.Close()
// This silences a TLS handshake error, caused by the dialer just immediately
// disconnecting, which we can just ignore.
tsTLS.Config.ErrorLog = log.New(ioutil.Discard, "", 0)
tsTLS.Config.ErrorLog = log.New(io.Discard, "", 0)
for _, testURL := range []string{ts.URL, tsTLS.URL} {
u, err := newParsedURL(testURL)
+2 -2
View File
@@ -3,7 +3,7 @@ package client
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"
@@ -76,7 +76,7 @@ func (c *URIClient) Call(ctx context.Context, method string,
}
defer resp.Body.Close()
responseBytes, err := ioutil.ReadAll(resp.Body)
responseBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("read response body: %w", err)
}