Skip to content

Commit 8a29a3a

Browse files
committed
Fix uses of deprecated io/ioutil package
1 parent 8493889 commit 8a29a3a

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

mega.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"errors"
1111
"fmt"
1212
"io"
13-
"io/ioutil"
1413
"log"
1514
"math/big"
1615
mrand "math/rand"
@@ -496,7 +495,7 @@ func (m *Mega) api_request(r []byte) (buf []byte, err error) {
496495
continue
497496
}
498497

499-
buf, err = ioutil.ReadAll(resp.Body)
498+
buf, err = io.ReadAll(resp.Body)
500499
if err != nil {
501500
_ = resp.Body.Close()
502501
continue
@@ -1170,7 +1169,7 @@ func (d *Download) DownloadChunk(id int) (chunk []byte, err error) {
11701169
return nil, errors.New("retries exceeded")
11711170
}
11721171

1173-
chunk, err = ioutil.ReadAll(resp.Body)
1172+
chunk, err = io.ReadAll(resp.Body)
11741173
if err != nil {
11751174
_ = resp.Body.Close()
11761175
return nil, err
@@ -1524,7 +1523,7 @@ func (u *Upload) UploadChunk(id int, chunk []byte) (err error) {
15241523
return errors.New("retries exceeded")
15251524
}
15261525

1527-
chunk_resp, err := ioutil.ReadAll(rsp.Body)
1526+
chunk_resp, err := io.ReadAll(rsp.Body)
15281527
if err != nil {
15291528
_ = rsp.Body.Close()
15301529
return err
@@ -1995,7 +1994,7 @@ func (m *Mega) pollEvents() {
19951994
continue
19961995
}
19971996

1998-
buf, err := ioutil.ReadAll(resp.Body)
1997+
buf, err := io.ReadAll(resp.Body)
19991998
if err != nil {
20001999
m.logf("pollEvents: Error reading body: %v", err)
20012000
_ = resp.Body.Close()

mega_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"crypto/rand"
66
"errors"
77
"fmt"
8-
"io/ioutil"
8+
"io"
99
"os"
1010
"path/filepath"
1111
"sync"
@@ -60,7 +60,7 @@ func createFile(t *testing.T, size int64) (string, string) {
6060
if err != nil {
6161
t.Fatalf("Error reading rand: %v", err)
6262
}
63-
file, err := ioutil.TempFile(os.TempDir(), "gomega-")
63+
file, err := os.CreateTemp(os.TempDir(), "gomega-")
6464
if err != nil {
6565
t.Fatalf("Error creating temp file: %v", err)
6666
}
@@ -121,7 +121,7 @@ func fileMD5(t *testing.T, name string) string {
121121
t.Fatalf("Error closing temp file: %v", err)
122122
}
123123
}()
124-
b, err := ioutil.ReadAll(file)
124+
b, err := io.ReadAll(file)
125125
if err != nil {
126126
t.Fatalf("Failed to read all %q: %v", name, err)
127127
}

0 commit comments

Comments
 (0)