@@ -10,7 +10,7 @@ import (
1010 "encoding/json"
1111 "errors"
1212 "fmt"
13- "io/ioutil "
13+ "io"
1414 "net/http"
1515 "net/http/httptest"
1616 "net/url"
@@ -70,7 +70,7 @@ func setup() (client *Client, mux *http.ServeMux, serverURL string, teardown fun
7070// directory, and create the file in that directory. It is the caller's
7171// responsibility to remove the directory and its contents when no longer needed.
7272func openTestFile (name , content string ) (file * os.File , dir string , err error ) {
73- dir , err = ioutil . TempDir ("" , "go-github" )
73+ dir , err = os . MkdirTemp ("" , "go-github" )
7474 if err != nil {
7575 return nil , dir , err
7676 }
@@ -133,7 +133,7 @@ func testURLParseError(t *testing.T, err error) {
133133
134134func testBody (t * testing.T , r * http.Request , want string ) {
135135 t .Helper ()
136- b , err := ioutil .ReadAll (r .Body )
136+ b , err := io .ReadAll (r .Body )
137137 if err != nil {
138138 t .Errorf ("Error reading request body: %v" , err )
139139 }
@@ -502,7 +502,7 @@ func TestNewRequest(t *testing.T) {
502502 }
503503
504504 // test that body was JSON encoded
505- body , _ := ioutil .ReadAll (req .Body )
505+ body , _ := io .ReadAll (req .Body )
506506 if got , want := string (body ), outBody ; got != want {
507507 t .Errorf ("NewRequest(%q) Body is %v, want %v" , inBody , got , want )
508508 }
@@ -617,7 +617,7 @@ func TestNewFormRequest(t *testing.T) {
617617 }
618618
619619 // test that body was form encoded
620- body , _ := ioutil .ReadAll (req .Body )
620+ body , _ := io .ReadAll (req .Body )
621621 if got , want := string (body ), outBody ; got != want {
622622 t .Errorf ("NewFormRequest(%q) Body is %v, want %v" , inBody , got , want )
623623 }
@@ -1398,7 +1398,7 @@ func TestCheckResponse(t *testing.T) {
13981398 res := & http.Response {
13991399 Request : & http.Request {},
14001400 StatusCode : http .StatusBadRequest ,
1401- Body : ioutil .NopCloser (strings .NewReader (`{"message":"m",
1401+ Body : io .NopCloser (strings .NewReader (`{"message":"m",
14021402 "errors": [{"resource": "r", "field": "f", "code": "c"}],
14031403 "block": {"reason": "dmca", "created_at": "2016-03-17T15:39:46Z"}}` )),
14041404 }
@@ -1427,7 +1427,7 @@ func TestCheckResponse_RateLimit(t *testing.T) {
14271427 Request : & http.Request {},
14281428 StatusCode : http .StatusForbidden ,
14291429 Header : http.Header {},
1430- Body : ioutil .NopCloser (strings .NewReader (`{"message":"m",
1430+ Body : io .NopCloser (strings .NewReader (`{"message":"m",
14311431 "documentation_url": "url"}` )),
14321432 }
14331433 res .Header .Set (headerRateLimit , "60" )
@@ -1454,7 +1454,7 @@ func TestCheckResponse_AbuseRateLimit(t *testing.T) {
14541454 res := & http.Response {
14551455 Request : & http.Request {},
14561456 StatusCode : http .StatusForbidden ,
1457- Body : ioutil .NopCloser (strings .NewReader (`{"message":"m",
1457+ Body : io .NopCloser (strings .NewReader (`{"message":"m",
14581458 "documentation_url": "docs.github.com/en/rest/overview/resources-in-the-rest-api#abuse-rate-limits"}` )),
14591459 }
14601460 err := CheckResponse (res ).(* AbuseRateLimitError )
@@ -1847,7 +1847,7 @@ func TestCheckResponse_noBody(t *testing.T) {
18471847 res := & http.Response {
18481848 Request : & http.Request {},
18491849 StatusCode : http .StatusBadRequest ,
1850- Body : ioutil .NopCloser (strings .NewReader ("" )),
1850+ Body : io .NopCloser (strings .NewReader ("" )),
18511851 }
18521852 err := CheckResponse (res ).(* ErrorResponse )
18531853
@@ -1868,7 +1868,7 @@ func TestCheckResponse_unexpectedErrorStructure(t *testing.T) {
18681868 res := & http.Response {
18691869 Request : & http.Request {},
18701870 StatusCode : http .StatusBadRequest ,
1871- Body : ioutil .NopCloser (strings .NewReader (httpBody )),
1871+ Body : io .NopCloser (strings .NewReader (httpBody )),
18721872 }
18731873 err := CheckResponse (res ).(* ErrorResponse )
18741874
@@ -1884,7 +1884,7 @@ func TestCheckResponse_unexpectedErrorStructure(t *testing.T) {
18841884 if ! errors .Is (err , want ) {
18851885 t .Errorf ("Error = %#v, want %#v" , err , want )
18861886 }
1887- data , err2 := ioutil .ReadAll (err .Response .Body )
1887+ data , err2 := io .ReadAll (err .Response .Body )
18881888 if err2 != nil {
18891889 t .Fatalf ("failed to read response body: %v" , err )
18901890 }
@@ -2373,9 +2373,9 @@ func TestBareDo_returnsOpenBody(t *testing.T) {
23732373 t .Fatalf ("client.BareDo returned error: %v" , err )
23742374 }
23752375
2376- got , err := ioutil .ReadAll (resp .Body )
2376+ got , err := io .ReadAll (resp .Body )
23772377 if err != nil {
2378- t .Fatalf ("ioutil .ReadAll returned error: %v" , err )
2378+ t .Fatalf ("io .ReadAll returned error: %v" , err )
23792379 }
23802380 if string (got ) != expectedBody {
23812381 t .Fatalf ("Expected %q, got %q" , expectedBody , string (got ))
0 commit comments