Skip to content

Commit 534bef4

Browse files
committed
ioutil -> io
Closes #27
1 parent 3302b6f commit 534bef4

File tree

12 files changed

+26
-26
lines changed

12 files changed

+26
-26
lines changed

internal/sdk/doc_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package sdk
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"net/http"
66
)
77

@@ -35,7 +35,7 @@ func (f *FakeMultiHTTPClient) Do(request *http.Request) (*http.Response, error)
3535

3636
func (f *FakeMultiHTTPClient) simulateServerReadingRequestBody(request *http.Request) {
3737
if request.Body != nil {
38-
body, _ := ioutil.ReadAll(request.Body)
38+
body, _ := io.ReadAll(request.Body)
3939
f.bodies = append(f.bodies, string(body))
4040
} else {
4141
f.bodies = append(f.bodies, request.URL.Query().Get("body"))

internal/sdk/http_sender.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package sdk
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"net/http"
66

77
"github.com/smartystreets/smartystreets-go-sdk"
@@ -38,7 +38,7 @@ func readResponseBody(response *http.Response) ([]byte, error) {
3838
// TODO: Since we already copy response.Body in retry_client.go -> readBody()
3939
// It would behoove us to prevent a second copy in that case.
4040

41-
if content, err := ioutil.ReadAll(response.Body); err != nil {
41+
if content, err := io.ReadAll(response.Body); err != nil {
4242
_ = response.Body.Close()
4343
return nil, err
4444
} else {

internal/sdk/keep_alive_close_client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package sdk
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"net/http"
66
"net/http/httptest"
77
"strings"
@@ -26,7 +26,7 @@ func (f *KeepAliveCloseClientFixture) Setup() {
2626
f.inner.response = &http.Response{
2727
ProtoMajor: 1, ProtoMinor: 1,
2828
StatusCode: http.StatusTeapot,
29-
Body: ioutil.NopCloser(strings.NewReader("Goodbye, World!")),
29+
Body: io.NopCloser(strings.NewReader("Goodbye, World!")),
3030
}
3131
f.request = httptest.NewRequest("GET", "/", nil)
3232
}

internal/sdk/retry_client.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package sdk
33
import (
44
"bytes"
55
"io"
6-
"io/ioutil"
76
"math/rand"
87
"net/http"
98
"sync"
@@ -54,13 +53,13 @@ func (r *RetryClient) doGet(request *http.Request) (response *http.Response, err
5453
}
5554

5655
func (r *RetryClient) doBufferedPost(request *http.Request) (response *http.Response, err error) {
57-
body, err := ioutil.ReadAll(request.Body)
56+
body, err := io.ReadAll(request.Body)
5857
if err != nil {
5958
return nil, err
6059
}
6160

6261
for attempt := 0; r.backOff(attempt); attempt++ {
63-
request.Body = ioutil.NopCloser(bytes.NewReader(body))
62+
request.Body = io.NopCloser(bytes.NewReader(body))
6463
if response, err = r.inner.Do(request); err == nil && response.StatusCode == http.StatusOK {
6564
if r.readBody(response) {
6665
break

us-extract-api/lookup.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package extract
22

33
import (
4-
"github.com/smartystreets/smartystreets-go-sdk/us-street-api"
5-
"io/ioutil"
4+
"io"
65
"net/http"
76
"strconv"
87
"strings"
8+
9+
"github.com/smartystreets/smartystreets-go-sdk/us-street-api"
910
)
1011

1112
// Lookup represents all input fields documented here:
@@ -64,7 +65,7 @@ func (l *Lookup) setBody(request *http.Request) {
6465
}
6566

6667
body := strings.NewReader(l.Text)
67-
request.Body = ioutil.NopCloser(body)
68+
request.Body = io.NopCloser(body)
6869
request.ContentLength = int64(body.Len())
6970
}
7071
func (l *Lookup) setHeaders(request *http.Request) {

us-extract-api/lookup_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package extract
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"net/http"
66
"net/url"
77
"testing"
@@ -33,7 +33,7 @@ func (f *LookupFixture) query() url.Values {
3333
}
3434

3535
func readBody(request *http.Request) string {
36-
bytes, _ := ioutil.ReadAll(request.Body)
36+
bytes, _ := io.ReadAll(request.Body)
3737
return string(bytes)
3838
}
3939

us-street-api/batch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package street
33
import (
44
"bytes"
55
"encoding/json"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
)
99

@@ -79,7 +79,7 @@ func (b *Batch) serializeGET(request *http.Request) {
7979
func (b *Batch) serializePOST(request *http.Request) {
8080
request.Method = http.MethodPost
8181
payload, _ := json.Marshal(b.lookups) // We control the types being serialized. This is safe.
82-
request.Body = ioutil.NopCloser(bytes.NewReader(payload))
82+
request.Body = io.NopCloser(bytes.NewReader(payload))
8383
request.ContentLength = int64(len(payload))
8484
request.Header.Set("Content-Type", "application/json")
8585
}

us-street-api/batch_processing_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package street
33
import (
44
"errors"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
"strconv"
99
"testing"
@@ -130,7 +130,7 @@ func (f *FakeMultiSender) Send(request *http.Request) ([]byte, error) {
130130
f.requests = append(f.requests, request)
131131

132132
if request.Body != nil {
133-
body, _ := ioutil.ReadAll(request.Body)
133+
body, _ := io.ReadAll(request.Body)
134134
f.requestBodies = append(f.requestBodies, string(body))
135135
}
136136

us-street-api/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package street
33
import (
44
"context"
55
"errors"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
"net/url"
99
"testing"
@@ -292,7 +292,7 @@ func (f *FakeSender) Send(request *http.Request) ([]byte, error) {
292292
f.callCount++
293293
f.request = request
294294
if request != nil && request.Body != nil {
295-
f.requestBody, _ = ioutil.ReadAll(request.Body)
295+
f.requestBody, _ = io.ReadAll(request.Body)
296296
}
297297
return []byte(f.response), f.err
298298
}

us-zipcode-api/batch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package zipcode
33
import (
44
"bytes"
55
"encoding/json"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
)
99

@@ -77,7 +77,7 @@ func (b *Batch) serializeGET(request *http.Request) {
7777
func (b *Batch) serializePOST(request *http.Request) {
7878
request.Method = http.MethodPost
7979
payload, _ := json.Marshal(b.lookups) // We control the types being serialized. This is safe.
80-
request.Body = ioutil.NopCloser(bytes.NewReader(payload))
80+
request.Body = io.NopCloser(bytes.NewReader(payload))
8181
request.ContentLength = int64(len(payload))
8282
request.Header.Set("Content-Type", "application/json")
8383
}

0 commit comments

Comments
 (0)