Skip to content

Commit e93546a

Browse files
committed
update go version
1 parent a1cde36 commit e93546a

File tree

9 files changed

+21
-25
lines changed

9 files changed

+21
-25
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/upyun/go-sdk/v3
22

3-
go 1.13
3+
go 1.17

upyun/errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"encoding/json"
55
"errors"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
)
1010

@@ -35,7 +35,7 @@ func checkResponse(res *http.Response) error {
3535
uerr.StatusCode = res.StatusCode
3636
uerr.Header = res.Header
3737
defer res.Body.Close()
38-
slurp, err := ioutil.ReadAll(res.Body)
38+
slurp, err := io.ReadAll(res.Body)
3939
if err != nil {
4040
return uerr
4141
}

upyun/form.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/json"
66
"fmt"
77
"io"
8-
"io/ioutil"
98
"mime/multipart"
109
"net/http"
1110
"os"
@@ -91,7 +90,7 @@ func (up *UpYun) FormUpload(config *FormUploadConfig) (*FormUploadResp, error) {
9190
return nil, err
9291
}
9392

94-
b, err := ioutil.ReadAll(resp.Body)
93+
b, err := io.ReadAll(resp.Body)
9594
resp.Body.Close()
9695

9796
if err != nil {

upyun/process.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
"path"
1010
"strings"
@@ -131,7 +131,7 @@ func (up *UpYun) doProcessRequest(method, uri string,
131131
return errorOperation("process", err)
132132
}
133133

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

218-
b, err := ioutil.ReadAll(resp.Body)
218+
b, err := io.ReadAll(resp.Body)
219219
resp.Body.Close()
220220
if err != nil {
221221
return nil, err

upyun/process_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package upyun
22

33
import (
44
"encoding/json"
5-
"io/ioutil"
5+
"io"
66
"net/http"
77
"path"
88
"testing"
@@ -69,7 +69,7 @@ func TestNagaResult(t *testing.T) {
6969
Equal(t, len(res), 2)
7070
}
7171

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

100100
}
101101

102-
//由于是异步操作,不能确保文件已存在
102+
// 由于是异步操作,不能确保文件已存在
103103
func TestVideoaudit(t *testing.T) {
104104
task := map[string]interface{}{
105105
"url": MP4_URL,
@@ -156,7 +156,7 @@ func TestFaceDetect(t *testing.T) {
156156
resp, err := http.Get(FACE_URL + "!/face/detection")
157157
Nil(t, err)
158158
defer resp.Body.Close()
159-
b, err := ioutil.ReadAll(resp.Body)
159+
b, err := io.ReadAll(resp.Body)
160160
Nil(t, err)
161161
if err != nil {
162162
var result map[string]interface{}

upyun/purge.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package upyun
22

33
import (
44
"encoding/json"
5-
"io/ioutil"
5+
"io"
66
URL "net/url"
77
"strings"
88
"time"
@@ -33,7 +33,7 @@ func (up *UpYun) Purge(urls []string) (fails []string, err error) {
3333
}
3434
defer resp.Body.Close()
3535

36-
content, err := ioutil.ReadAll(resp.Body)
36+
content, err := io.ReadAll(resp.Body)
3737
if err != nil {
3838
return fails, errorOperation("purge read body", err)
3939
}

upyun/rest.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"io"
99
"io/fs"
10-
"io/ioutil"
1110
"net"
1211
"net/http"
1312
"os"
@@ -532,7 +531,7 @@ func (up *UpYun) ListMultipartUploads(config *ListMultipartConfig) (*ListMultipa
532531
return nil, errorOperation("list multipart", err)
533532
}
534533

535-
body, err := ioutil.ReadAll(res.Body)
534+
body, err := io.ReadAll(res.Body)
536535
if err != nil {
537536
return nil, errorOperation("list multipart read body", err)
538537
}
@@ -563,7 +562,7 @@ func (up *UpYun) ListMultipartParts(intiResult *InitMultipartUploadResult, confi
563562
return nil, errorOperation("list multipart parts", err)
564563
}
565564

566-
body, err := ioutil.ReadAll(res.Body)
565+
body, err := io.ReadAll(res.Body)
567566
if err != nil {
568567
return nil, errorOperation("list multipart parts read body", err)
569568
}
@@ -688,7 +687,7 @@ func (up *UpYun) List(config *GetObjectsConfig) error {
688687
return errorOperation("list", err)
689688
}
690689

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

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

900899
if config.closeBody {
901-
io.Copy(ioutil.Discard, resp.Body)
900+
io.Copy(io.Discard, resp.Body)
902901
resp.Body.Close()
903902
}
904903

upyun/rest_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package upyun
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
76
"net"
87
"os"
98
"path"
@@ -367,10 +366,10 @@ func TestGetWithLocalPath(t *testing.T) {
367366
_, err = os.Stat(LOCAL_SAVE_FILE)
368367
Nil(t, err)
369368

370-
b1, err := ioutil.ReadFile(LOCAL_FILE)
369+
b1, err := os.ReadFile(LOCAL_FILE)
371370
Nil(t, err)
372371

373-
b2, err := ioutil.ReadFile(LOCAL_SAVE_FILE)
372+
b2, err := os.ReadFile(LOCAL_SAVE_FILE)
374373
Nil(t, err)
375374

376375
Equal(t, string(b1), string(b2))

upyun/utils.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"encoding/json"
99
"fmt"
1010
"io"
11-
"io/ioutil"
1211
"net/http"
1312
"net/url"
1413
"os"
@@ -143,7 +142,7 @@ func unescapeUri(s string) string {
143142
return string(t)
144143
}
145144

146-
var readHTTPBody = ioutil.ReadAll
145+
var readHTTPBody = io.ReadAll
147146

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

0 commit comments

Comments
 (0)