Skip to content

Commit

Permalink
chore: remove refs to deprecated io/ioutil
Browse files Browse the repository at this point in the history
Signed-off-by: guoguangwu <guoguangwug@gmail.com>
  • Loading branch information
testwill authored and felipejfc committed Jun 25, 2024
1 parent 11965de commit 68da1bc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions acceptor/tcp_acceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"crypto/tls"
"fmt"
"io"
"io/ioutil"
"net"

"github.com/topfreegames/pitaya/v2/conn/codec"
Expand Down Expand Up @@ -53,7 +52,7 @@ func (t *tcpPlayerConn) RemoteAddr() net.Addr {

// GetNextMessage reads the next message available in the stream
func (t *tcpPlayerConn) GetNextMessage() (b []byte, err error) {
header, err := ioutil.ReadAll(io.LimitReader(t.Conn, codec.HeadLength))
header, err := io.ReadAll(io.LimitReader(t.Conn, codec.HeadLength))
if err != nil {
return nil, err
}
Expand All @@ -65,7 +64,7 @@ func (t *tcpPlayerConn) GetNextMessage() (b []byte, err error) {
if err != nil {
return nil, err
}
msgData, err := ioutil.ReadAll(io.LimitReader(t.Conn, int64(msgSize)))
msgData, err := io.ReadAll(io.LimitReader(t.Conn, int64(msgSize)))
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions client/protoclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"strings"
"time"

Expand Down Expand Up @@ -81,7 +81,7 @@ func unpackDescriptor(compressedDescriptor []byte) (*protobuf.FileDescriptorProt
}
defer r.Close()

b, err := ioutil.ReadAll(r)
b, err := io.ReadAll(r)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"bufio"
"errors"
"fmt"
"io/ioutil"
"net"
"os"
"os/exec"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -73,15 +73,15 @@ func GetTestEtcd(t *testing.T) (*integration.ClusterV3, *clientv3.Client) {
// WriteFile test helper
func WriteFile(t *testing.T, filepath string, bytes []byte) {
t.Helper()
if err := ioutil.WriteFile(filepath, bytes, 0644); err != nil {
if err := os.WriteFile(filepath, bytes, 0644); err != nil {
t.Fatalf("failed writing file: %s", err)
}
}

// ReadFile test helper
func ReadFile(t *testing.T, filepath string) []byte {
t.Helper()
b, err := ioutil.ReadFile(filepath)
b, err := os.ReadFile(filepath)
if err != nil {
t.Fatalf("failed reading file: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions logger/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
tests "github.com/sirupsen/logrus/hooks/test"
"github.com/topfreegames/pitaya/v2/logger/interfaces"
lwrapper "github.com/topfreegames/pitaya/v2/logger/logrus"
"io/ioutil"
"io"
)

// NewNullLogger creates a discarding logger and installs the test hook.
func NewNullLogger() (interfaces.Logger, *tests.Hook) {
logger, hook := tests.NewNullLogger()
logger.Out = ioutil.Discard
logger.Out = io.Discard
return lwrapper.NewWithFieldLogger(logger), hook
}
4 changes: 2 additions & 2 deletions util/compression/compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package compression
import (
"bytes"
"compress/zlib"
"io/ioutil"
"io"
)

func DeflateData(data []byte) ([]byte, error) {
Expand All @@ -24,7 +24,7 @@ func InflateData(data []byte) ([]byte, error) {
}
defer zr.Close()

return ioutil.ReadAll(zr)
return io.ReadAll(zr)
}

func IsCompressed(data []byte) bool {
Expand Down

0 comments on commit 68da1bc

Please sign in to comment.