chore: remove refs to deprecated io/ioutil
This commit is contained in:
parent
20f5ddb4af
commit
7036f221f4
|
@ -2,7 +2,7 @@ package bencode
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func loadFile(name string, t *testing.T) []byte {
|
||||
data, err := ioutil.ReadFile(name)
|
||||
data, err := os.ReadFile(name)
|
||||
require.NoError(t, err)
|
||||
return data
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
|
@ -107,7 +106,7 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
tmpdir, err := ioutil.TempDir("", "torrent-pick-")
|
||||
tmpdir, err := os.MkdirTemp("", "torrent-pick-")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
package testutil
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
|
@ -41,7 +40,7 @@ func GreetingMetaInfo() *metainfo.MetaInfo {
|
|||
// and a corresponding metainfo describing it. The temporary directory can be
|
||||
// cleaned away with os.RemoveAll.
|
||||
func GreetingTestTorrent() (tempDir string, metaInfo *metainfo.MetaInfo) {
|
||||
tempDir, err := ioutil.TempDir(os.TempDir(), "")
|
||||
tempDir, err := os.MkdirTemp(os.TempDir(), "")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package testutil
|
|||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/anacrolix/missinggo/expect"
|
||||
|
@ -53,7 +52,7 @@ func (t *Torrent) Info(pieceLength int64) metainfo.Info {
|
|||
}
|
||||
}
|
||||
err := info.GeneratePieces(func(fi metainfo.FileInfo) (io.ReadCloser, error) {
|
||||
return ioutil.NopCloser(strings.NewReader(t.GetFile(strings.Join(fi.Path, "/")).Data)), nil
|
||||
return io.NopCloser(strings.NewReader(t.GetFile(strings.Join(fi.Path, "/")).Data)), nil
|
||||
})
|
||||
expect.Nil(err)
|
||||
return info
|
||||
|
|
|
@ -5,7 +5,6 @@ package torrent
|
|||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -38,5 +37,5 @@ func TestDropTorrentWithMmapStorageWhileHashing(t *testing.T) {
|
|||
|
||||
r := tt.NewReader()
|
||||
go tt.Drop()
|
||||
io.Copy(ioutil.Discard, r)
|
||||
io.Copy(io.Discard, r)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package metainfo
|
|||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
@ -68,7 +67,7 @@ func TestNumPieces(t *testing.T) {
|
|||
PieceLength: _case.PieceLength,
|
||||
}
|
||||
err := info.GeneratePieces(func(fi FileInfo) (io.ReadCloser, error) {
|
||||
return ioutil.NopCloser(missinggo.ZeroReader), nil
|
||||
return io.NopCloser(missinggo.ZeroReader), nil
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, _case.NumPieces, info.NumPieces())
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"expvar"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/big"
|
||||
"strconv"
|
||||
|
@ -409,7 +408,7 @@ func (h *handshake) initerSteps() (ret io.ReadWriter, selected CryptoMethod, err
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = io.CopyN(ioutil.Discard, r, int64(padLen))
|
||||
_, err = io.CopyN(io.Discard, r, int64(padLen))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -474,7 +473,7 @@ func (h *handshake) receiverSteps() (ret io.ReadWriter, chosen CryptoMethod, err
|
|||
}
|
||||
cryptoProvidesCount.Add(strconv.FormatUint(uint64(provides), 16), 1)
|
||||
chosen = h.chooseMethod(provides)
|
||||
_, err = io.CopyN(ioutil.Discard, r, int64(padLen))
|
||||
_, err = io.CopyN(io.Discard, r, int64(padLen))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"crypto/rand"
|
||||
"crypto/rc4"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"sync"
|
||||
"testing"
|
||||
|
@ -131,7 +130,7 @@ func (tr *trackReader) Read(b []byte) (n int, err error) {
|
|||
|
||||
func TestReceiveRandomData(t *testing.T) {
|
||||
tr := trackReader{rand.Reader, 0}
|
||||
_, _, err := ReceiveHandshake(readWriter{&tr, ioutil.Discard}, nil, DefaultCryptoSelector)
|
||||
_, _, err := ReceiveHandshake(readWriter{&tr, io.Discard}, nil, DefaultCryptoSelector)
|
||||
// No skey matches
|
||||
require.Error(t, err)
|
||||
// Establishing S, and then reading the maximum padding for giving up on
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
@ -141,7 +140,7 @@ func (s piecePerResourcePiece) MarkComplete() error {
|
|||
if ccr, ok := s.rp.(ConsecutiveChunkReader); ok {
|
||||
return ccr.ReadConsecutiveChunks(s.incompleteDirPath() + "/")
|
||||
}
|
||||
return ioutil.NopCloser(io.NewSectionReader(incompleteChunks, 0, s.mp.Length())), nil
|
||||
return io.NopCloser(io.NewSectionReader(incompleteChunks, 0, s.mp.Length())), nil
|
||||
}()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting incomplete chunks reader: %w", err)
|
||||
|
|
|
@ -2,7 +2,6 @@ package test
|
|||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
|
@ -46,7 +45,7 @@ func newFileCacheClientStorageFactory(ps fileCacheClientStorageFactoryParams) St
|
|||
storage.ResourcePiecesOpts{
|
||||
Capacity: sharedCapacity,
|
||||
}),
|
||||
ioutil.NopCloser(nil),
|
||||
io.NopCloser(nil),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"crypto/rand"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net"
|
||||
"net/url"
|
||||
"sync"
|
||||
|
@ -179,7 +179,7 @@ func TestURLPathOption(t *testing.T) {
|
|||
r = bytes.NewReader(b[:n])
|
||||
udp.Read(r, &h)
|
||||
udp.Read(r, &AnnounceRequest{})
|
||||
all, _ := ioutil.ReadAll(r)
|
||||
all, _ := io.ReadAll(r)
|
||||
if string(all) != "\x02\x09/announce" {
|
||||
t.FailNow()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue