bencode/both_test.go | 4 ++-- cmd/torrent-pick/main.go | 3 +-- internal/testutil/greeting.go | 3 +-- internal/testutil/spec.go | 3 +-- issue211_test.go | 3 +-- metainfo/metainfo_test.go | 3 +-- mse/mse.go | 5 ++--- mse/mse_test.go | 3 +-- storage/piece-resource.go | 3 +-- test/transfer_test.go | 3 +-- tracker/udp_test.go | 4 ++-- diff --git a/bencode/both_test.go b/bencode/both_test.go index b0bb074d38af6b17e236e06a19a5105528a4f499..fdcb90d9f8e44184039c3c6aa825b79d1a6f6667 100644 --- a/bencode/both_test.go +++ b/bencode/both_test.go @@ -2,7 +2,7 @@ package bencode import ( "bytes" - "io/ioutil" + "os" "testing" "github.com/stretchr/testify/assert" @@ -10,7 +10,7 @@ "github.com/stretchr/testify/require" ) func loadFile(name string, t *testing.T) []byte { - data, err := ioutil.ReadFile(name) + data, err := os.ReadFile(name) require.NoError(t, err) return data } diff --git a/cmd/torrent-pick/main.go b/cmd/torrent-pick/main.go index 8dd5a773c24485ef1ff3f48e27e6c8c505ab54e1..73a597f3622024604c26e22a9cfeba7d079a66bd 100644 --- a/cmd/torrent-pick/main.go +++ b/cmd/torrent-pick/main.go @@ -5,7 +5,6 @@ import ( "bufio" "fmt" "io" - "io/ioutil" "log" "net" "net/http" @@ -107,7 +106,7 @@ fmt.Fprintln(os.Stderr, "no torrents specified") return } - tmpdir, err := ioutil.TempDir("", "torrent-pick-") + tmpdir, err := os.MkdirTemp("", "torrent-pick-") if err != nil { log.Fatal(err) } diff --git a/internal/testutil/greeting.go b/internal/testutil/greeting.go index 954ad9130d55fa644f02c5e946dfc5a249b48d5e..6544483c8b312690764518f4f8be1bfeb241d09f 100644 --- a/internal/testutil/greeting.go +++ b/internal/testutil/greeting.go @@ -6,7 +6,6 @@ package testutil import ( - "io/ioutil" "os" "path/filepath" @@ -41,7 +40,7 @@ // Gives a temporary directory containing the completed "greeting" torrent, // 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) } diff --git a/internal/testutil/spec.go b/internal/testutil/spec.go index 42d91ba3cfa34b96609145ff16f65ea2eca36f29..63e4a74c633f646bdb1efa7c1607684cf0b807d9 100644 --- a/internal/testutil/spec.go +++ b/internal/testutil/spec.go @@ -2,7 +2,6 @@ package testutil import ( "io" - "io/ioutil" "strings" "github.com/anacrolix/missinggo/expect" @@ -53,7 +52,7 @@ }) } } 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 diff --git a/issue211_test.go b/issue211_test.go index 7794f8a50137974993485f57d1a14f30f3d5a913..a76be07a8a2da0a6c6682e28038eb610a9d8f140 100644 --- a/issue211_test.go +++ b/issue211_test.go @@ -5,7 +5,6 @@ package torrent import ( "io" - "io/ioutil" "testing" "github.com/stretchr/testify/assert" @@ -38,5 +37,5 @@ assert.True(t, new) r := tt.NewReader() go tt.Drop() - io.Copy(ioutil.Discard, r) + io.Copy(io.Discard, r) } diff --git a/metainfo/metainfo_test.go b/metainfo/metainfo_test.go index d1a6c356c42fa83d304f754e22db963edfdfdea7..335631f9850c7ba6b135612c38ed89958e48bfa9 100644 --- a/metainfo/metainfo_test.go +++ b/metainfo/metainfo_test.go @@ -2,7 +2,6 @@ package metainfo import ( "io" - "io/ioutil" "os" "path" "path/filepath" @@ -68,7 +67,7 @@ Files: _case.Files, 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()) diff --git a/mse/mse.go b/mse/mse.go index a5477b8f172706af718565cc59a2928651e0b9d5..c3a9f3d3ae840c77eed1c37a881111194ae71c9f 100644 --- a/mse/mse.go +++ b/mse/mse.go @@ -12,7 +12,6 @@ "errors" "expvar" "fmt" "io" - "io/ioutil" "math" "math/big" "strconv" @@ -409,7 +408,7 @@ err = unmarshal(r, &method, &padLen) 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 @@ return } 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 } diff --git a/mse/mse_test.go b/mse/mse_test.go index a38e9cc109aec619fb38ce7199312dd5979b5d60..f7f7fe7ab9c7f2090f2a30467cc5635414dbdc8d 100644 --- a/mse/mse_test.go +++ b/mse/mse_test.go @@ -5,7 +5,6 @@ "bytes" "crypto/rand" "crypto/rc4" "io" - "io/ioutil" "net" "sync" "testing" @@ -131,7 +130,7 @@ } 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 diff --git a/storage/piece-resource.go b/storage/piece-resource.go index ec3848df2111186259ce1cb76c9f6749aa8623f9..5327f31d1b10e5ca08b1ffeb03e4e76af8ca39c4 100644 --- a/storage/piece-resource.go +++ b/storage/piece-resource.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "path" "sort" "strconv" @@ -141,7 +140,7 @@ r, err := func() (io.ReadCloser, 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) diff --git a/test/transfer_test.go b/test/transfer_test.go index 683d589b897059c1b76b24491c66bedecdcc7773..501872fd8fb642971aedd1134ce91f0df16b4574 100644 --- a/test/transfer_test.go +++ b/test/transfer_test.go @@ -2,7 +2,6 @@ package test import ( "io" - "io/ioutil" "os" "sync" "testing" @@ -46,7 +45,7 @@ fc.AsResourceProvider(), storage.ResourcePiecesOpts{ Capacity: sharedCapacity, }), - ioutil.NopCloser(nil), + io.NopCloser(nil), } } } diff --git a/tracker/udp_test.go b/tracker/udp_test.go index cf18e0de9f2dc20fc07f7f13fd9a6b99fc48fe03..232aeb1973a51f0229b6591894473ea4a61c94c8 100644 --- a/tracker/udp_test.go +++ b/tracker/udp_test.go @@ -6,7 +6,7 @@ "context" "crypto/rand" "errors" "fmt" - "io/ioutil" + "io" "net" "net/url" "sync" @@ -179,7 +179,7 @@ n, _, _ := conn.ReadFrom(b[:]) 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() }