Skip to content

Commit a36a925

Browse files
authored
Remove last uses of io/ioutil (#1054)
This package has been deprecated since Go 1.16, most of the uses were removed in #962, these are the remaining few.
1 parent 7d93ee3 commit a36a925

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

‎middleware/compress_test.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"compress/gzip"
66
"fmt"
77
"io"
8-
"io/ioutil"
98
"net/http"
109
"net/http/httptest"
1110
"strings"
@@ -207,7 +206,7 @@ func decodeResponseBody(t *testing.T, resp *http.Response) string {
207206
default:
208207
reader = resp.Body
209208
}
210-
respBody, err := ioutil.ReadAll(reader)
209+
respBody, err := io.ReadAll(reader)
211210
if err != nil {
212211
t.Fatal(err)
213212
return ""

‎middleware/throttle_test.go‎

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

33
import (
4-
"io/ioutil"
4+
"io"
55
"net/http"
66
"net/http/httptest"
77
"strings"
@@ -46,7 +46,7 @@ func TestThrottleBacklog(t *testing.T) {
4646
assertNoError(t, err)
4747

4848
assertEqual(t, http.StatusOK, res.StatusCode)
49-
buf, err := ioutil.ReadAll(res.Body)
49+
buf, err := io.ReadAll(res.Body)
5050
assertNoError(t, err)
5151
assertEqual(t, testContent, buf)
5252
}(i)
@@ -131,7 +131,7 @@ func TestThrottleTriggerGatewayTimeout(t *testing.T) {
131131
res, err := client.Get(server.URL)
132132
assertNoError(t, err)
133133

134-
buf, err := ioutil.ReadAll(res.Body)
134+
buf, err := io.ReadAll(res.Body)
135135
assertNoError(t, err)
136136
assertEqual(t, http.StatusTooManyRequests, res.StatusCode)
137137
assertEqual(t, errTimedOut, strings.TrimSpace(string(buf)))
@@ -170,7 +170,7 @@ func TestThrottleMaximum(t *testing.T) {
170170
assertNoError(t, err)
171171
assertEqual(t, http.StatusOK, res.StatusCode)
172172

173-
buf, err := ioutil.ReadAll(res.Body)
173+
buf, err := io.ReadAll(res.Body)
174174
assertNoError(t, err)
175175
assertEqual(t, testContent, buf)
176176
}(i)
@@ -189,7 +189,7 @@ func TestThrottleMaximum(t *testing.T) {
189189
res, err := client.Get(server.URL)
190190
assertNoError(t, err)
191191

192-
buf, err := ioutil.ReadAll(res.Body)
192+
buf, err := io.ReadAll(res.Body)
193193
assertNoError(t, err)
194194
assertEqual(t, http.StatusTooManyRequests, res.StatusCode)
195195
assertEqual(t, errCapacityExceeded, strings.TrimSpace(string(buf)))

0 commit comments

Comments
 (0)