change: replace ioutil.ReadAll with io.ReadAll

This commit is contained in:
lilong.129
2023-08-29 17:27:54 +08:00
parent 97430bf451
commit b64fe9cfdd
6 changed files with 10 additions and 12 deletions

View File

@@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"math/rand"
"net/http"
"net/url"
@@ -176,7 +176,7 @@ func (g *GA4Client) SendEvent(event Event) error {
return nil
}
bs, err = ioutil.ReadAll(res.Body)
bs, err = io.ReadAll(res.Body)
if err != nil {
return errors.Wrap(err, "read GA4 response body failed")
}

View File

@@ -3,7 +3,6 @@ package gadb
import (
"fmt"
"io"
"io/ioutil"
"net"
"regexp"
"strconv"
@@ -97,7 +96,7 @@ func (t transport) ReadStringAll() (s string, err error) {
}
func (t transport) ReadBytesAll() (raw []byte, err error) {
raw, err = ioutil.ReadAll(t.sock)
raw, err = io.ReadAll(t.sock)
return
}

View File

@@ -5,7 +5,6 @@ import (
"encoding/binary"
"fmt"
"io"
"io/ioutil"
"strings"
"time"
@@ -109,7 +108,7 @@ func (c *PcapdClient) GetPacket(buf []byte) ([]byte, error) {
}
}
packet, err := ioutil.ReadAll(preader)
packet, err := io.ReadAll(preader)
if err != nil {
return packet, err
}

View File

@@ -72,7 +72,7 @@ func (wd *Driver) httpRequest(method string, rawURL string, rawBody []byte) (raw
_ = resp.Body.Close()
}()
rawResp, err = ioutil.ReadAll(resp.Body)
rawResp, err = io.ReadAll(resp.Body)
logger := log.Debug().Int("statusCode", resp.StatusCode).Str("duration", time.Since(start).String())
if !strings.HasSuffix(rawURL, "screenshot") {
// avoid printing screenshot data

View File

@@ -7,7 +7,7 @@ import (
"fmt"
"image"
"image/color"
"io/ioutil"
"io"
"math"
"os"
@@ -133,7 +133,7 @@ func getBufFromDisk(name string) (*bytes.Buffer, error) {
return nil, err
}
var all []byte
if all, err = ioutil.ReadAll(f); err != nil {
if all, err = io.ReadAll(f); err != nil {
return nil, err
}
return bytes.NewBuffer(all), nil
@@ -361,7 +361,7 @@ func getMatsFromDisk(nameImage, nameTpl string, flags gocv.IMReadFlag) (matImage
// return nil, e
// }
// var all []byte
// if all, e = ioutil.ReadAll(f); e != nil {
// if all, e = io.ReadAll(f); e != nil {
// return nil, e
// }
// return bytes.NewBuffer(all), nil

View File

@@ -4,7 +4,7 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"strings"
@@ -42,7 +42,7 @@ func parseBody(r *http.Request) (data map[string]interface{}, err error) {
// Always set resp.Data to the incoming request body, in case we don't know
// how to handle the content type
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
r.Body.Close()
return nil, err