chore: remove refs to deprecated io/ioutil (#5519)

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
pull/5526/head
guangwu 2023-11-16 19:16:15 +08:00 committed by GitHub
parent 3d51845f57
commit f904596cbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -5,7 +5,6 @@ import (
"crypto/x509" "crypto/x509"
"encoding/pem" "encoding/pem"
"fmt" "fmt"
"io/ioutil"
"net/http" "net/http"
"os" "os"
"regexp" "regexp"
@ -44,7 +43,7 @@ func (d *GoogleDrive) refreshToken() error {
gdsaFileThis := d.RefreshToken gdsaFileThis := d.RefreshToken
if gdsaFile.IsDir() { if gdsaFile.IsDir() {
if len(d.ServiceAccountFileList) <= 0 { if len(d.ServiceAccountFileList) <= 0 {
gdsaReadDir, gdsaDirErr := ioutil.ReadDir(d.RefreshToken) gdsaReadDir, gdsaDirErr := os.ReadDir(d.RefreshToken)
if gdsaDirErr != nil { if gdsaDirErr != nil {
log.Error("read dir fail") log.Error("read dir fail")
return gdsaDirErr return gdsaDirErr
@ -76,7 +75,7 @@ func (d *GoogleDrive) refreshToken() error {
} }
} }
gdsaFileThisContent, err := ioutil.ReadFile(gdsaFileThis) gdsaFileThisContent, err := os.ReadFile(gdsaFileThis)
if err != nil { if err != nil {
return err return err
} }

View File

@ -8,7 +8,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"sync" "sync"
"testing" "testing"
@ -169,7 +168,7 @@ func newDownloadRangeClient(data []byte) (*downloadCaptureClient, *int, *[]strin
header := &http.Header{} header := &http.Header{}
header.Set("Content-Range", fmt.Sprintf("bytes %d-%d/%d", start, fin-1, len(data))) header.Set("Content-Range", fmt.Sprintf("bytes %d-%d/%d", start, fin-1, len(data)))
return &http.Response{ return &http.Response{
Body: ioutil.NopCloser(bytes.NewReader(bodyBytes)), Body: io.NopCloser(bytes.NewReader(bodyBytes)),
Header: *header, Header: *header,
ContentLength: int64(len(bodyBytes)), ContentLength: int64(len(bodyBytes)),
}, nil }, nil