Skip to content

Commit

Permalink
refactor: replace use of the deprecated ioutil package
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneM committed Nov 16, 2021
1 parent 34d93b1 commit 04a824c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package scalingo

import (
"encoding/json"
"io/ioutil"
"io"
"strconv"
"time"

"github.com/Scalingo/go-scalingo/v4/http"

"gopkg.in/errgo.v1"

"github.com/Scalingo/go-scalingo/v4/http"
)

type AddonsService interface {
Expand Down Expand Up @@ -169,7 +169,7 @@ func (c *Client) AddonLogsArchives(app, addonID string, page int) (*LogsArchives
return nil, errgo.Notef(err, "fail to get log archives")
}

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, errgo.Notef(err, "fail to read body of response")
}
Expand Down
9 changes: 5 additions & 4 deletions auth_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package scalingo
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"net/http"
"time"

"github.com/golang-jwt/jwt/v4"
"github.com/golang/mock/gomock"

httpclient "github.com/Scalingo/go-scalingo/v4/http"
"github.com/Scalingo/go-scalingo/v4/http/httpmock"
jwt "github.com/golang-jwt/jwt/v4"
gomock "github.com/golang/mock/gomock"
)

func MockAuth(ctrl *gomock.Controller) *httpmock.MockClient {
Expand All @@ -27,7 +28,7 @@ func MockAuth(ctrl *gomock.Controller) *httpmock.MockClient {
}

return &http.Response{
Body: ioutil.NopCloser(bytes.NewBuffer([]byte(fmt.Sprintf(`{"token": "%v"}`, jwt)))),
Body: io.NopCloser(bytes.NewBuffer([]byte(fmt.Sprintf(`{"token": "%v"}`, jwt)))),
}, nil
}).AnyTimes()
return mock
Expand Down
3 changes: 1 addition & 2 deletions http/api_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"reflect"
Expand Down Expand Up @@ -145,7 +144,7 @@ func (c *client) doRequest(req *http.Request) (*http.Response, error) {
}

func parseJSON(res *http.Response, data interface{}) error {
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
reqErr := fmt.Sprintf("%v %v", res.Request.Method, res.Request.URL)
return errgo.Newf("fail to read body of request %v: %v", reqErr, err)
Expand Down
6 changes: 3 additions & 3 deletions logs-archives.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package scalingo

import (
"encoding/json"
"io/ioutil"
"io"
"strconv"

"gopkg.in/errgo.v1"
Expand Down Expand Up @@ -43,7 +43,7 @@ func (c *Client) LogsArchivesByCursor(app string, cursor string) (*LogsArchivesR
return nil, errgo.Mask(err)
}

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, errgo.Mask(err)
}
Expand Down Expand Up @@ -74,7 +74,7 @@ func (c *Client) LogsArchives(app string, page int) (*LogsArchivesResponse, erro
return nil, errgo.Mask(err)
}

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, errgo.Mask(err)
}
Expand Down

0 comments on commit 04a824c

Please sign in to comment.