ioutil is deprecated, use io package instead

This commit is contained in:
Julien Laffaye 2022-08-18 11:18:54 -04:00
parent 9cda78131d
commit 5a2fd50da8
No known key found for this signature in database
GPG Key ID: 890C3E5C169AE841

View File

@ -3,7 +3,7 @@ package ftp
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"io/ioutil" "io"
"net" "net"
"syscall" "syscall"
"testing" "testing"
@ -56,7 +56,7 @@ func testConn(t *testing.T, disableEPSV bool) {
// Read without deadline // Read without deadline
r, err := c.Retr("tset") r, err := c.Retr("tset")
if assert.NoError(err) { if assert.NoError(err) {
buf, err := ioutil.ReadAll(r) buf, err := io.ReadAll(r)
if assert.NoError(err) { if assert.NoError(err) {
assert.Equal(testData, string(buf)) assert.Equal(testData, string(buf))
} }
@ -71,7 +71,7 @@ func testConn(t *testing.T, disableEPSV bool) {
if err := r.SetDeadline(time.Now()); err != nil { if err := r.SetDeadline(time.Now()); err != nil {
t.Fatal(err) t.Fatal(err)
} }
_, err = ioutil.ReadAll(r) _, err = io.ReadAll(r)
assert.ErrorContains(err, "i/o timeout") assert.ErrorContains(err, "i/o timeout")
r.Close() r.Close()
} }
@ -79,7 +79,7 @@ func testConn(t *testing.T, disableEPSV bool) {
// Read with offset // Read with offset
r, err = c.RetrFrom("tset", 5) r, err = c.RetrFrom("tset", 5)
if assert.NoError(err) { if assert.NoError(err) {
buf, err := ioutil.ReadAll(r) buf, err := io.ReadAll(r)
if assert.NoError(err) { if assert.NoError(err) {
expected := testData[5:] expected := testData[5:]
assert.Equal(expected, string(buf)) assert.Equal(expected, string(buf))
@ -95,7 +95,7 @@ func testConn(t *testing.T, disableEPSV bool) {
// Read without deadline, after append // Read without deadline, after append
r, err = c.Retr("tset") r, err = c.Retr("tset")
if assert.NoError(err) { if assert.NoError(err) {
buf, err := ioutil.ReadAll(r) buf, err := io.ReadAll(r)
if assert.NoError(err) { if assert.NoError(err) {
assert.Equal(testData+testData, string(buf)) assert.Equal(testData+testData, string(buf))
} }