Skip to content

Commit 65c6e7b

Browse files
committed
chore: remove refs to deprecated io/ioutil
1 parent 80cb1b8 commit 65c6e7b

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

defaults/router_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package defaults
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"net/http"
66
"net/http/httptest"
77
"strings"
@@ -16,23 +16,23 @@ func TestRouter(t *testing.T) {
1616
wantGet, wantPost, wantDelete := "testget", "testpost", "testdelete"
1717

1818
r.Get("/test", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
19-
b, err := ioutil.ReadAll(r.Body)
19+
b, err := io.ReadAll(r.Body)
2020
if err != nil {
2121
panic(err)
2222
}
2323

2424
get = string(b)
2525
}))
2626
r.Post("/test", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
27-
b, err := ioutil.ReadAll(r.Body)
27+
b, err := io.ReadAll(r.Body)
2828
if err != nil {
2929
panic(err)
3030
}
3131

3232
post = string(b)
3333
}))
3434
r.Delete("/test", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
35-
b, err := ioutil.ReadAll(r.Body)
35+
b, err := io.ReadAll(r.Body)
3636
if err != nil {
3737
panic(err)
3838
}

defaults/smtp_mailer_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"encoding/json"
66
"flag"
77
"fmt"
8-
"io/ioutil"
98
"net/smtp"
9+
"os"
1010
"testing"
1111

1212
"github.com/volatiletech/authboss/v3"
@@ -30,7 +30,7 @@ func TestSMTPMailer(t *testing.T) {
3030
Password string `json:"password,omitempty"`
3131
}{}
3232

33-
b, err := ioutil.ReadFile("smtp_mailer_test.json")
33+
b, err := os.ReadFile("smtp_mailer_test.json")
3434
if err != nil {
3535
t.Fatal(`error reading file: "smtp_mailer_test.json`, err)
3636
}

defaults/values.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package defaults
22

33
import (
44
"encoding/json"
5-
"io/ioutil"
5+
"io"
66
"net/http"
77
"net/url"
88
"regexp"
@@ -214,7 +214,7 @@ func (h HTTPBodyReader) Read(page string, r *http.Request) (authboss.Validator,
214214
var values map[string]string
215215

216216
if h.ReadJSON {
217-
b, err := ioutil.ReadAll(r.Body)
217+
b, err := io.ReadAll(r.Body)
218218
r.Body.Close()
219219
if err != nil {
220220
return nil, errors.Wrap(err, "failed to read http body")

oauth2/providers.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package oauth2
33
import (
44
"context"
55
"encoding/json"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88

99
"github.com/friendsofgo/errors"
@@ -40,7 +40,7 @@ func GoogleUserDetails(ctx context.Context, cfg oauth2.Config, token *oauth2.Tok
4040
}
4141

4242
defer resp.Body.Close()
43-
byt, err := ioutil.ReadAll(resp.Body)
43+
byt, err := io.ReadAll(resp.Body)
4444
if err != nil {
4545
return nil, errors.Wrap(err, "failed to read body from google oauth2 endpoint")
4646
}
@@ -72,7 +72,7 @@ func FacebookUserDetails(ctx context.Context, cfg oauth2.Config, token *oauth2.T
7272
}
7373

7474
defer resp.Body.Close()
75-
byt, err := ioutil.ReadAll(resp.Body)
75+
byt, err := io.ReadAll(resp.Body)
7676
if err != nil {
7777
return nil, errors.Wrap(err, "failed to read body from facebook oauth2 endpoint")
7878
}

oauth2/providers_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package oauth2
22

33
import (
44
"context"
5-
"io/ioutil"
5+
"io"
66
"net/http"
77
"strings"
88
"testing"
@@ -16,7 +16,7 @@ func init() {
1616
// get, but it'll safely be ignored.
1717
clientGet = func(_ *http.Client, url string) (*http.Response, error) {
1818
return &http.Response{
19-
Body: ioutil.NopCloser(strings.NewReader(`{"id":"id", "email":"email", "name": "name"}`)),
19+
Body: io.NopCloser(strings.NewReader(`{"id":"id", "email":"email", "name": "name"}`)),
2020
}, nil
2121
}
2222
}

0 commit comments

Comments
 (0)