Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated of packageio/ioutil #913

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions middleware/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"strings"
Expand Down Expand Up @@ -160,12 +159,12 @@ func (c *Compressor) SetEncoder(encoding string, fn EncoderFunc) {
delete(c.encoders, encoding)

// If the encoder supports Resetting (IoReseterWriter), then it can be pooled.
encoder := fn(ioutil.Discard, c.level)
encoder := fn(io.Discard, c.level)
if encoder != nil {
if _, ok := encoder.(ioResetterWriter); ok {
pool := &sync.Pool{
New: func() interface{} {
return fn(ioutil.Discard, c.level)
return fn(io.Discard, c.level)
},
}
c.pooledEncoders[encoding] = pool
Expand Down
3 changes: 1 addition & 2 deletions middleware/compress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"strings"
Expand Down Expand Up @@ -208,7 +207,7 @@ func decodeResponseBody(t *testing.T, resp *http.Response) string {
default:
reader = resp.Body
}
respBody, err := ioutil.ReadAll(reader)
respBody, err := io.ReadAll(reader)
if err != nil {
t.Fatal(err)
return ""
Expand Down
5 changes: 2 additions & 3 deletions middleware/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package middleware
import (
"crypto/tls"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"path"
Expand Down Expand Up @@ -93,7 +92,7 @@ func testRequest(t *testing.T, ts *httptest.Server, method, path string, body io
return nil, ""
}

respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
return nil, ""
Expand Down Expand Up @@ -123,7 +122,7 @@ func testRequestNoRedirect(t *testing.T, ts *httptest.Server, method, path strin
return nil, ""
}

respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
return nil, ""
Expand Down
10 changes: 5 additions & 5 deletions middleware/throttle_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package middleware

import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"strings"
Expand Down Expand Up @@ -46,7 +46,7 @@ func TestThrottleBacklog(t *testing.T) {
assertNoError(t, err)

assertEqual(t, http.StatusOK, res.StatusCode)
buf, err := ioutil.ReadAll(res.Body)
buf, err := io.ReadAll(res.Body)
assertNoError(t, err)
assertEqual(t, testContent, buf)
}(i)
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestThrottleTriggerGatewayTimeout(t *testing.T) {
res, err := client.Get(server.URL)
assertNoError(t, err)

buf, err := ioutil.ReadAll(res.Body)
buf, err := io.ReadAll(res.Body)
assertNoError(t, err)
assertEqual(t, http.StatusTooManyRequests, res.StatusCode)
assertEqual(t, errTimedOut, strings.TrimSpace(string(buf)))
Expand Down Expand Up @@ -172,7 +172,7 @@ func TestThrottleMaximum(t *testing.T) {
assertNoError(t, err)
assertEqual(t, http.StatusOK, res.StatusCode)

buf, err := ioutil.ReadAll(res.Body)
buf, err := io.ReadAll(res.Body)
assertNoError(t, err)
assertEqual(t, testContent, buf)

Expand All @@ -192,7 +192,7 @@ func TestThrottleMaximum(t *testing.T) {
res, err := client.Get(server.URL)
assertNoError(t, err)

buf, err := ioutil.ReadAll(res.Body)
buf, err := io.ReadAll(res.Body)
assertNoError(t, err)
assertEqual(t, http.StatusTooManyRequests, res.StatusCode)
assertEqual(t, errCapacityExceeded, strings.TrimSpace(string(buf)))
Expand Down
7 changes: 3 additions & 4 deletions mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -186,7 +185,7 @@ func TestMuxBasic(t *testing.T) {
t.Fatal(err)
}

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -1368,7 +1367,7 @@ func TestServeHTTPExistingContext(t *testing.T) {
}
req = req.WithContext(tc.Ctx)
r.ServeHTTP(resp, req)
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatalf("%v", err)
}
Expand Down Expand Up @@ -1855,7 +1854,7 @@ func testRequest(t *testing.T, ts *httptest.Server, method, path string, body io
return nil, ""
}

respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
return nil, ""
Expand Down
Loading