refactor: change deprecated "io/ioutil" package to recommended "io" package

This commit is contained in:
am3o 2024-02-17 12:47:22 +01:00
parent 35984c0876
commit acce1f1fd9
No known key found for this signature in database
GPG key ID: F76214F50EEA64B5
14 changed files with 25 additions and 39 deletions

View file

@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
@ -87,7 +86,7 @@ func TestWrite(t *testing.T) {
// goroutine, reading from the Conn s and writing to the dataCh
// and errCh channels, whose ultimate effect in the select loop
// below is like
// data, err := ioutil.ReadAll(s)
// data, err := io.ReadAll(s)
dataCh := make(chan []byte)
errCh := make(chan error)
go func() {
@ -162,7 +161,7 @@ func TestConcurrentRead(t *testing.T) {
for i := 0; i < 2; i++ {
go func() {
defer wg.Done()
_, err := io.Copy(ioutil.Discard, s)
_, err := io.Copy(io.Discard, s)
if err != nil {
errCh <- err
}
@ -224,7 +223,7 @@ func TestConcurrentWrite(t *testing.T) {
}()
// Read from the other end.
_, err = io.Copy(ioutil.Discard, c)
_, err = io.Copy(io.Discard, c)
c.Close()
if err != nil {
t.Fatalf("Read: %v", err)
@ -336,7 +335,7 @@ func BenchmarkUpgradeBufferSize(b *testing.B) {
func BenchmarkReadWrite(b *testing.B) {
trial := func(b *testing.B, readConn, writeConn *Conn, msgSize int) {
go func() {
io.Copy(ioutil.Discard, readConn)
io.Copy(io.Discard, readConn)
}()
data := make([]byte, msgSize)
b.ResetTimer()