Skip to content

Commit

Permalink
Replace usage of the deprecated "io/ioutil" package (GEA-12683)
Browse files Browse the repository at this point in the history
"io/ioutil" has been deprecated since Go v1.16.
  • Loading branch information
kenany committed Feb 21, 2024
1 parent 18aec5f commit e5d2b3a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Rewrote `README.md`.
- Replaced usage of the deprecated io/ioutil package.

## [3.6.0] - 2024-01-16

Expand Down
1 change: 1 addition & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
6 changes: 3 additions & 3 deletions pangea-sdk/v3/internal/arweave/arweave.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"

"github.com/pangeacyber/pangea-go/pangea-sdk/v3/internal/defaults"
Expand Down Expand Up @@ -38,7 +38,7 @@ func (a *Arweave) TransactionByID(ctx context.Context, id string) ([]byte, error
return nil, fmt.Errorf("arweave: GET %v with status code %v", url, resp.StatusCode)
}

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("arweave: GET %v failed to read response body: %w", url, err)
}
Expand Down Expand Up @@ -86,7 +86,7 @@ func (a *Arweave) TransactionConnectionByTags(ctx context.Context, tags TagFilte
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("arweave: POST %v with status code %v", url, resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("arweave: POST %v failed to read response body: %w", url, err)
}
Expand Down
8 changes: 4 additions & 4 deletions pangea-sdk/v3/internal/pangeatesting/pangeatesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package pangeatesting

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestMethod(t *testing.T, r *http.Request, want string) {

func TestBody(t *testing.T, r *http.Request, want string) {
t.Helper()
b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
if err != nil {
t.Fatalf("Error reading request body: %v", err)
}
Expand Down Expand Up @@ -93,9 +93,9 @@ func TestNewRequestAndDoFailure(t *testing.T, method string, f func(cfg *pangea.
func CreateFile(t *testing.T, contents []byte) *os.File {
t.Helper()
tmpdir := t.TempDir()
file, err := ioutil.TempFile(tmpdir, "*")
file, err := os.CreateTemp(tmpdir, "*")
if err != nil {
t.Fatal("failed to creat temp file")
t.Fatal("failed to create temp file")
}
file.Write(contents)
return file
Expand Down
4 changes: 2 additions & 2 deletions pangea-sdk/v3/pangea/pangea_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"testing"

Expand Down Expand Up @@ -159,7 +159,7 @@ func TestDo_Request_With_Body_Sends_Request_With_Json_Body(t *testing.T) {

mux.HandleFunc("/test", func(w http.ResponseWriter, r *http.Request) {
body := &reqbody{}
data, _ := ioutil.ReadAll(r.Body)
data, _ := io.ReadAll(r.Body)
json.Unmarshal(data, body)
if body.Key == nil && *body.Key != "value" {
w.WriteHeader(http.StatusInternalServerError)
Expand Down

0 comments on commit e5d2b3a

Please sign in to comment.