Skip to content

Commit

Permalink
update go version
Browse files Browse the repository at this point in the history
  • Loading branch information
huangnauh committed Oct 28, 2024
1 parent a1cde36 commit e93546a
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/upyun/go-sdk/v3

go 1.13
go 1.17
4 changes: 2 additions & 2 deletions upyun/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
)

Expand Down Expand Up @@ -35,7 +35,7 @@ func checkResponse(res *http.Response) error {
uerr.StatusCode = res.StatusCode
uerr.Header = res.Header
defer res.Body.Close()
slurp, err := ioutil.ReadAll(res.Body)
slurp, err := io.ReadAll(res.Body)
if err != nil {
return uerr
}
Expand Down
3 changes: 1 addition & 2 deletions upyun/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
Expand Down Expand Up @@ -91,7 +90,7 @@ func (up *UpYun) FormUpload(config *FormUploadConfig) (*FormUploadResp, error) {
return nil, err
}

b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
resp.Body.Close()

if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions upyun/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"path"
"strings"
Expand Down Expand Up @@ -131,7 +131,7 @@ func (up *UpYun) doProcessRequest(method, uri string,
return errorOperation("process", err)
}

b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return errorOperation("process read body", err)
Expand Down Expand Up @@ -215,7 +215,7 @@ func (up *UpYun) doSyncProcessRequest(method, uri string, payload string) (map[s
return nil, errorOperation("sync process", err)
}

b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions upyun/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package upyun

import (
"encoding/json"
"io/ioutil"
"io"
"net/http"
"path"
"testing"
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestNagaResult(t *testing.T) {
Equal(t, len(res), 2)
}

//由于是异步操作,不能确保文件已存在
// 由于是异步操作,不能确保文件已存在
func TestImgaudit(t *testing.T) {
task := map[string]interface{}{
"url": JPG_URL,
Expand Down Expand Up @@ -99,7 +99,7 @@ func TestImgaudit(t *testing.T) {

}

//由于是异步操作,不能确保文件已存在
// 由于是异步操作,不能确保文件已存在
func TestVideoaudit(t *testing.T) {
task := map[string]interface{}{
"url": MP4_URL,
Expand Down Expand Up @@ -156,7 +156,7 @@ func TestFaceDetect(t *testing.T) {
resp, err := http.Get(FACE_URL + "!/face/detection")
Nil(t, err)
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
Nil(t, err)
if err != nil {
var result map[string]interface{}
Expand Down
4 changes: 2 additions & 2 deletions upyun/purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package upyun

import (
"encoding/json"
"io/ioutil"
"io"
URL "net/url"
"strings"
"time"
Expand Down Expand Up @@ -33,7 +33,7 @@ func (up *UpYun) Purge(urls []string) (fails []string, err error) {
}
defer resp.Body.Close()

content, err := ioutil.ReadAll(resp.Body)
content, err := io.ReadAll(resp.Body)
if err != nil {
return fails, errorOperation("purge read body", err)
}
Expand Down
11 changes: 5 additions & 6 deletions upyun/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"io"
"io/fs"
"io/ioutil"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -532,7 +531,7 @@ func (up *UpYun) ListMultipartUploads(config *ListMultipartConfig) (*ListMultipa
return nil, errorOperation("list multipart", err)
}

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, errorOperation("list multipart read body", err)
}
Expand Down Expand Up @@ -563,7 +562,7 @@ func (up *UpYun) ListMultipartParts(intiResult *InitMultipartUploadResult, confi
return nil, errorOperation("list multipart parts", err)
}

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, errorOperation("list multipart parts read body", err)
}
Expand Down Expand Up @@ -688,7 +687,7 @@ func (up *UpYun) List(config *GetObjectsConfig) error {
return errorOperation("list", err)
}

b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return errorOperation("list read body", err)
Expand Down Expand Up @@ -796,7 +795,7 @@ func (up *UpYun) ListObjects(config *ListObjectsConfig) (fileInfos []*FileInfo,
}

// 读取列表
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return nil, "", errorOperation("list read body", err)
Expand Down Expand Up @@ -898,7 +897,7 @@ func (up *UpYun) doRESTRequest(config *restReqConfig) (*http.Response, error) {
}

if config.closeBody {
io.Copy(ioutil.Discard, resp.Body)
io.Copy(io.Discard, resp.Body)
resp.Body.Close()
}

Expand Down
5 changes: 2 additions & 3 deletions upyun/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package upyun
import (
"bytes"
"fmt"
"io/ioutil"
"net"
"os"
"path"
Expand Down Expand Up @@ -367,10 +366,10 @@ func TestGetWithLocalPath(t *testing.T) {
_, err = os.Stat(LOCAL_SAVE_FILE)
Nil(t, err)

b1, err := ioutil.ReadFile(LOCAL_FILE)
b1, err := os.ReadFile(LOCAL_FILE)
Nil(t, err)

b2, err := ioutil.ReadFile(LOCAL_SAVE_FILE)
b2, err := os.ReadFile(LOCAL_SAVE_FILE)
Nil(t, err)

Equal(t, string(b1), string(b2))
Expand Down
3 changes: 1 addition & 2 deletions upyun/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -143,7 +142,7 @@ func unescapeUri(s string) string {
return string(t)
}

var readHTTPBody = ioutil.ReadAll
var readHTTPBody = io.ReadAll

func readHTTPBodyToStr(resp *http.Response) (string, error) {
b, err := readHTTPBody(resp.Body)
Expand Down

0 comments on commit e93546a

Please sign in to comment.