discard <ioutil.ReadAll>

This commit is contained in:
14March
2023-08-16 18:43:29 +08:00
parent 3d6efeec33
commit 4554984653
6 changed files with 12 additions and 12 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ package protocol
import (
"bytes"
"io/ioutil"
"io"
"github.com/golang/snappy"
"github.com/smallnest/rpcx/util"
@@ -67,7 +67,7 @@ func (c *SnappyCompressor) Unzip(data []byte) ([]byte, error) {
}
reader := snappy.NewReader(bytes.NewReader(data))
out, err := ioutil.ReadAll(reader)
out, err := io.ReadAll(reader)
if err != nil {
return nil, err
}
+2 -2
View File
@@ -1,7 +1,7 @@
package server
import (
"io/ioutil"
"io"
"net/http"
"net/url"
"strconv"
@@ -85,7 +85,7 @@ func HTTPRequest2RpcxRequest(r *http.Request) (*protocol.Message, error) {
req.ServiceMethod = h.Get(XServiceMethod)
payload, err := ioutil.ReadAll(r.Body)
payload, err := io.ReadAll(r.Body)
if err != nil {
return nil, err
}
+2 -2
View File
@@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"errors"
"io/ioutil"
"io"
"net"
"net/http"
"net/url"
@@ -18,7 +18,7 @@ import (
)
func (s *Server) jsonrpcHandler(w http.ResponseWriter, r *http.Request) {
data, err := ioutil.ReadAll(r.Body)
data, err := io.ReadAll(r.Body)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
+2 -2
View File
@@ -4,7 +4,7 @@ import (
"bytes"
"context"
"encoding/json"
"io/ioutil"
"io"
"net"
"testing"
"time"
@@ -166,7 +166,7 @@ func TestHandler(t *testing.T) {
serverConn.Close()
}()
data, err = ioutil.ReadAll(clientConn)
data, err = io.ReadAll(clientConn)
assert.NoError(t, err)
resp, err := protocol.Read(bytes.NewReader(data))
+2 -2
View File
@@ -3,7 +3,7 @@ package util
import (
"bytes"
"compress/gzip"
"io/ioutil"
"io"
"sync"
)
@@ -39,7 +39,7 @@ func Unzip(data []byte) ([]byte, error) {
}
defer gr.Close()
data, err = ioutil.ReadAll(gr)
data, err = io.ReadAll(gr)
if err != nil {
return nil, err
}
+2 -2
View File
@@ -3,7 +3,7 @@ package util
import (
"bytes"
"compress/gzip"
"io/ioutil"
"io"
"testing"
)
@@ -78,7 +78,7 @@ func oldUnzip(data []byte) ([]byte, error) {
}
defer gr.Close()
data, err = ioutil.ReadAll(gr)
data, err = io.ReadAll(gr)
if err != nil {
return nil, err
}