From 02f393be3ff114214b3c84d4ae570ba1d06fd756 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Thu, 23 Mar 2023 15:04:17 +0800 Subject: [PATCH 01/17] Delete .travis.yml --- .travis.yml | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a2492d6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: go - -go: - - 1.12.x - -branches: # build only on these branches - only: - - master - -install: - - export GO111MODULE=on - -notifications: - webhooks: https://oapi.dingtalk.com/robot/send?access_token=096ed387df243a6d60835aadeccc47165f3813bc7cb81cdd0cfeadfd28e3acc1 - email: false - on_success: change - on_failure: always - -script: - - go mod tidy - - go test -race -coverprofile=coverage.txt -covermode=atomic ./tea/... ./utils/... - -after_success: - - bash <(curl -s https://codecov.io/bash) From 8a7c8512f875b35cb83a122447bfd6f4f447dadb Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Wed, 26 Apr 2023 11:18:45 +0800 Subject: [PATCH 02/17] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index df35475..4e7c794 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ Latest Stable Version codecov -Travis Build Status +[![Go CI](https://github.com/alibabacloud-go/tea/actions/workflows/go.yml/badge.svg)](https://github.com/alibabacloud-go/tea/actions/workflows/go.yml) -This project is used for support TEA OpenAPI DSL. It's a low-level library for http request. +This project is used for support Darabonba OpenAPI DSL. It's a low-level library for http request. ## License [Apache-2.0](/LICENSE) -Copyright (c) 2009-present, Alibaba Cloud All rights reserved. \ No newline at end of file +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. From c4f78703d745615bce5bddffa19d6750cd7ac0d6 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Wed, 26 Apr 2023 11:20:13 +0800 Subject: [PATCH 03/17] Update README-CN.md --- README-CN.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README-CN.md b/README-CN.md index de45fb5..80a0fa5 100644 --- a/README-CN.md +++ b/README-CN.md @@ -2,11 +2,11 @@ Latest Stable Version codecov -Travis Build Status +[![Go CI](https://github.com/alibabacloud-go/tea/actions/workflows/go.yml/badge.svg)](https://github.com/alibabacloud-go/tea/actions/workflows/go.yml) -该项目用于支持TEA OpenAPI DSL。它是http请求的底层库. +该项目用于支持 Darabonba OpenAPI DSL。它是http请求的底层库. ## 许可证 [Apache-2.0](/LICENSE) -Copyright (c) 2009-present, Alibaba Cloud All rights reserved. \ No newline at end of file +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. From 636d89faa76a276154d91249de75da236e1e1807 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Wed, 26 Apr 2023 11:27:31 +0800 Subject: [PATCH 04/17] Create dependabot.yml --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..e0871f9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "gomod" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" From b46b464236893a14953aab0e63d74991910593a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Apr 2023 03:28:21 +0000 Subject: [PATCH 05/17] Bump github.com/json-iterator/go from 1.1.10 to 1.1.12 Bumps [github.com/json-iterator/go](https://github.com/json-iterator/go) from 1.1.10 to 1.1.12. - [Release notes](https://github.com/json-iterator/go/releases) - [Commits](https://github.com/json-iterator/go/compare/v1.1.10...v1.1.12) --- updated-dependencies: - dependency-name: github.com/json-iterator/go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 8e76f97..6ebbd40 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.14 require ( github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 - github.com/json-iterator/go v1.1.10 - github.com/modern-go/reflect2 v1.0.1 + github.com/json-iterator/go v1.1.12 + github.com/modern-go/reflect2 v1.0.2 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) From e158cc5dc597533f74e2b0bfdaa3f300718a3c0f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Apr 2023 03:30:11 +0000 Subject: [PATCH 06/17] Bump golang.org/x/net from 0.0.0-20200226121028-0de0cce0169b to 0.9.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.0.0-20200226121028-0de0cce0169b to 0.9.0. - [Release notes](https://github.com/golang/net/releases) - [Commits](https://github.com/golang/net/commits/v0.9.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6ebbd40..608c000 100644 --- a/go.mod +++ b/go.mod @@ -6,5 +6,5 @@ require ( github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 github.com/json-iterator/go v1.1.12 github.com/modern-go/reflect2 v1.0.2 - golang.org/x/net v0.0.0-20200226121028-0de0cce0169b + golang.org/x/net v0.9.0 ) From 07ca3b69ad17c423dca13224c1e530db2a07aa23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=90=86=E6=83=B3?= Date: Wed, 26 Apr 2023 15:56:22 +0800 Subject: [PATCH 07/17] deal with MaxIdleConns, MaxIdleConnsPerHost, TLSHandshakeTimeout, and KeepAlive --- tea/tea.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tea/tea.go b/tea/tea.go index 975ad81..e63c08e 100644 --- a/tea/tea.go +++ b/tea/tea.go @@ -476,6 +476,9 @@ func getHttpTransport(req *Request, runtime *RuntimeObject) (*http.Transport, er } else { trans.DialContext = setDialContext(runtime) } + trans.MaxIdleConns = IntValue(runtime.MaxIdleConns) + trans.MaxIdleConnsPerHost = IntValue(runtime.MaxIdleConns) + trans.TLSHandshakeTimeout = 30 * time.Second return trans, nil } @@ -581,11 +584,13 @@ func setDialContext(runtime *RuntimeObject) func(cxt context.Context, net, addr Timeout: time.Duration(IntValue(runtime.ConnectTimeout)) * time.Second, DualStack: true, LocalAddr: netAddr, + KeepAlive: 30 * time.Second, }).DialContext(ctx, network, address) } return (&net.Dialer{ Timeout: time.Duration(IntValue(runtime.ConnectTimeout)) * time.Second, DualStack: true, + KeepAlive: 30 * time.Second, }).DialContext(ctx, network, address) } } From 712238a5c4aaf48e3e21e44c0d6121bfdd1dfefe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=90=86=E6=83=B3?= Date: Thu, 27 Apr 2023 09:47:36 +0800 Subject: [PATCH 08/17] remove keep alive default --- tea/tea.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tea/tea.go b/tea/tea.go index e63c08e..6c7fadb 100644 --- a/tea/tea.go +++ b/tea/tea.go @@ -476,9 +476,10 @@ func getHttpTransport(req *Request, runtime *RuntimeObject) (*http.Transport, er } else { trans.DialContext = setDialContext(runtime) } - trans.MaxIdleConns = IntValue(runtime.MaxIdleConns) - trans.MaxIdleConnsPerHost = IntValue(runtime.MaxIdleConns) - trans.TLSHandshakeTimeout = 30 * time.Second + if runtime.MaxIdleConns != nil { + trans.MaxIdleConns = IntValue(runtime.MaxIdleConns) + trans.MaxIdleConnsPerHost = IntValue(runtime.MaxIdleConns) + } return trans, nil } @@ -584,13 +585,11 @@ func setDialContext(runtime *RuntimeObject) func(cxt context.Context, net, addr Timeout: time.Duration(IntValue(runtime.ConnectTimeout)) * time.Second, DualStack: true, LocalAddr: netAddr, - KeepAlive: 30 * time.Second, }).DialContext(ctx, network, address) } return (&net.Dialer{ Timeout: time.Duration(IntValue(runtime.ConnectTimeout)) * time.Second, DualStack: true, - KeepAlive: 30 * time.Second, }).DialContext(ctx, network, address) } } From cb3a42bc23a2d74f28dddc23b65f9755d30743d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=90=86=E6=83=B3?= Date: Mon, 8 May 2023 16:46:06 +0800 Subject: [PATCH 09/17] judge maxidleconns int(0) pointer --- tea/tea.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tea/tea.go b/tea/tea.go index 6c7fadb..db2e50a 100644 --- a/tea/tea.go +++ b/tea/tea.go @@ -476,7 +476,7 @@ func getHttpTransport(req *Request, runtime *RuntimeObject) (*http.Transport, er } else { trans.DialContext = setDialContext(runtime) } - if runtime.MaxIdleConns != nil { + if runtime.MaxIdleConns != nil && *runtime.MaxIdleConns > 0 { trans.MaxIdleConns = IntValue(runtime.MaxIdleConns) trans.MaxIdleConnsPerHost = IntValue(runtime.MaxIdleConns) } From aa99f50b3f99ab1b5a24a661c1d14199b34da95c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 07:05:42 +0000 Subject: [PATCH 10/17] Bump golang.org/x/net from 0.9.0 to 0.10.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.9.0 to 0.10.0. - [Commits](https://github.com/golang/net/compare/v0.9.0...v0.10.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 608c000..89da22f 100644 --- a/go.mod +++ b/go.mod @@ -6,5 +6,5 @@ require ( github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 github.com/json-iterator/go v1.1.12 github.com/modern-go/reflect2 v1.0.2 - golang.org/x/net v0.9.0 + golang.org/x/net v0.10.0 ) From 121efa4413dd4ea7029d730fa6c79094bdda51b6 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Mon, 15 May 2023 15:38:22 +0800 Subject: [PATCH 11/17] update actions setup-go to v4 --- .github/workflows/go.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 6885e63..92007f6 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Set up Go 1.x - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: go-version: ${{ matrix.go }} @@ -32,4 +32,4 @@ jobs: run: go test -race -coverprofile=coverage.txt -covermode=atomic ./tea/... ./utils/... - name: CodeCov - run: bash <(curl -s https://codecov.io/bash) \ No newline at end of file + run: bash <(curl -s https://codecov.io/bash) From 5ef2fcc54fbf108a03ca5b87c78c39743e723780 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Jun 2023 07:04:24 +0000 Subject: [PATCH 12/17] Bump golang.org/x/net from 0.10.0 to 0.11.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.10.0 to 0.11.0. - [Commits](https://github.com/golang/net/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 89da22f..a337850 100644 --- a/go.mod +++ b/go.mod @@ -6,5 +6,5 @@ require ( github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 github.com/json-iterator/go v1.1.12 github.com/modern-go/reflect2 v1.0.2 - golang.org/x/net v0.10.0 + golang.org/x/net v0.11.0 ) From e3922d2afb33ea33101b674e9d9e2e66493a5cdf Mon Sep 17 00:00:00 2001 From: nanhe Date: Tue, 27 Jun 2023 23:30:47 +0800 Subject: [PATCH 13/17] improve tls client config --- tea/tea.go | 44 +++++++++++++++++++++++--------------------- tea/tea_test.go | 16 ++++++++++++++-- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/tea/tea.go b/tea/tea.go index db2e50a..041dd64 100644 --- a/tea/tea.go +++ b/tea/tea.go @@ -415,28 +415,30 @@ func getHttpTransport(req *Request, runtime *RuntimeObject) (*http.Transport, er if err != nil { return nil, err } - if strings.ToLower(*req.Protocol) == "https" && - runtime.Key != nil && runtime.Cert != nil { - cert, err := tls.X509KeyPair([]byte(StringValue(runtime.Cert)), []byte(StringValue(runtime.Key))) - if err != nil { - return nil, err - } - - trans.TLSClientConfig = &tls.Config{ - Certificates: []tls.Certificate{cert}, - InsecureSkipVerify: BoolValue(runtime.IgnoreSSL), - } - if runtime.CA != nil { - clientCertPool := x509.NewCertPool() - ok := clientCertPool.AppendCertsFromPEM([]byte(StringValue(runtime.CA))) - if !ok { - return nil, errors.New("Failed to parse root certificate") + if strings.ToLower(*req.Protocol) == "https" { + if BoolValue(runtime.IgnoreSSL) != true { + trans.TLSClientConfig = &tls.Config{ + InsecureSkipVerify: false, + } + if runtime.Key != nil && runtime.Cert != nil && StringValue(runtime.Key) != "" && StringValue(runtime.Cert) != "" { + cert, err := tls.X509KeyPair([]byte(StringValue(runtime.Cert)), []byte(StringValue(runtime.Key))) + if err != nil { + return nil, err + } + trans.TLSClientConfig.Certificates = []tls.Certificate{cert} + } + if runtime.CA != nil && StringValue(runtime.CA) != "" { + clientCertPool := x509.NewCertPool() + ok := clientCertPool.AppendCertsFromPEM([]byte(StringValue(runtime.CA))) + if !ok { + return nil, errors.New("Failed to parse root certificate") + } + trans.TLSClientConfig.RootCAs = clientCertPool + } + } else { + trans.TLSClientConfig = &tls.Config{ + InsecureSkipVerify: true, } - trans.TLSClientConfig.RootCAs = clientCertPool - } - } else { - trans.TLSClientConfig = &tls.Config{ - InsecureSkipVerify: BoolValue(runtime.IgnoreSSL), } } if httpProxy != nil { diff --git a/tea/tea_test.go b/tea/tea_test.go index f9fd2f8..297456f 100644 --- a/tea/tea_test.go +++ b/tea/tea_test.go @@ -542,20 +542,32 @@ func Test_DoRequest(t *testing.T) { runtimeObj["key"] = "private rsa key" runtimeObj["cert"] = "private certification" + runtimeObj["ca"] = "private ca" runtimeObj["ignoreSSL"] = true resp, err = DoRequest(request, runtimeObj) + utils.AssertNil(t, err) + utils.AssertNotNil(t, resp) + + // update the host is to restart a client + request.Headers["host"] = String("a.com") + runtimeObj["ignoreSSL"] = false + resp, err = DoRequest(request, runtimeObj) utils.AssertNotNil(t, err) + utils.AssertEqual(t, "tls: failed to find any PEM data in certificate input", err.Error()) utils.AssertNil(t, resp) + // update the host is to restart a client + request.Headers["host"] = String("b.com") runtimeObj["key"] = key runtimeObj["cert"] = cert runtimeObj["ca"] = "private ca" - runtimeObj["socks5Proxy"] = "socks5://someuser:somepassword@cs.aliyun.com" _, err = DoRequest(request, runtimeObj) utils.AssertNotNil(t, err) + utils.AssertEqual(t, "Failed to parse root certificate", err.Error()) + // update the host is to restart a client + request.Headers["host"] = String("c.com") runtimeObj["ca"] = ca - runtimeObj["socks5Proxy"] = "socks5://someuser:somepassword@cs.aliyuncs.com" resp, err = DoRequest(request, runtimeObj) utils.AssertNil(t, err) utils.AssertEqual(t, "test", StringValue(resp.Headers["tea"])) From 2b0e131d0014b50942d672be7a704b749556d073 Mon Sep 17 00:00:00 2001 From: nanhe Date: Wed, 28 Jun 2023 17:46:15 +0800 Subject: [PATCH 14/17] docs: update comments --- tea/tea.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tea/tea.go b/tea/tea.go index 041dd64..c984caf 100644 --- a/tea/tea.go +++ b/tea/tea.go @@ -262,7 +262,7 @@ func Convert(in interface{}, out interface{}) error { return err } -// Convert is use convert map[string]interface object to struct +// Recover is used to format error func Recover(in interface{}) error { if in == nil { return nil From b81493c626ef0719d7486c1a4705f35a834ddd98 Mon Sep 17 00:00:00 2001 From: yndu13 Date: Mon, 22 Jan 2024 16:23:29 +0800 Subject: [PATCH 15/17] fix: unescape unicode in sdk error --- .github/workflows/go.yml | 2 +- .gitignore | 3 +-- go.sum | 54 ++++++++++++++++++++++++++++++++++++++++ tea/tea.go | 7 ++++-- tea/tea_test.go | 3 ++- 5 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 go.sum diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 92007f6..82a6b3e 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: [1.13, 1.14, 1.15] + go: ["1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "1.19", "1.20"] steps: - name: Set up Go 1.x diff --git a/.gitignore b/.gitignore index 786cac6..4497994 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ coverage.html coverage.txt coverage.out .DS_Store -.history/ -go.sum \ No newline at end of file +.history/ \ No newline at end of file diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..135e3b7 --- /dev/null +++ b/go.sum @@ -0,0 +1,54 @@ +github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 h1:NqugFkGxx1TXSh/pBcU00Y6bljgDPaFdh5MUSeJ7e50= +github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68/go.mod h1:6pb/Qy8c+lqua8cFpEy7g39NRRqOWc3rOwAy8m5Y2BY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/tea/tea.go b/tea/tea.go index c984caf..3fc9b08 100644 --- a/tea/tea.go +++ b/tea/tea.go @@ -218,8 +218,11 @@ func NewSDKError(obj map[string]interface{}) *SDKError { } } } - byt, _ := json.Marshal(data) - err.Data = String(string(byt)) + byt := bytes.NewBuffer([]byte{}) + jsonEncoder := json.NewEncoder(byt) + jsonEncoder.SetEscapeHTML(false) + jsonEncoder.Encode(data) + err.Data = String(string(bytes.TrimSpace(byt.Bytes()))) } if statusCode, ok := obj["statusCode"].(int); ok { diff --git a/tea/tea_test.go b/tea/tea_test.go index 297456f..272a030 100644 --- a/tea/tea_test.go +++ b/tea/tea_test.go @@ -168,6 +168,7 @@ func TestSDKError(t *testing.T) { "httpCode": "404", "requestId": "dfadfa32cgfdcasd4313", "hostId": "github.com/alibabacloud/tea", + "recommend": "https://中文?q=a.b&product=c&requestId=123", }, "description": "description", "accessDeniedDetail": map[string]interface{}{ @@ -179,7 +180,7 @@ func TestSDKError(t *testing.T) { }, }) utils.AssertNotNil(t, err) - utils.AssertEqual(t, "SDKError:\n StatusCode: 404\n Code: code\n Message: message\n Data: {\"hostId\":\"github.com/alibabacloud/tea\",\"httpCode\":\"404\",\"requestId\":\"dfadfa32cgfdcasd4313\"}\n", err.Error()) + utils.AssertEqual(t, "SDKError:\n StatusCode: 404\n Code: code\n Message: message\n Data: {\"hostId\":\"github.com/alibabacloud/tea\",\"httpCode\":\"404\",\"recommend\":\"https://中文?q=a.b&product=c&requestId=123\",\"requestId\":\"dfadfa32cgfdcasd4313\"}\n", err.Error()) err.SetErrMsg("test") utils.AssertEqual(t, "test", err.Error()) From d755295be2cb342bfdbec1a29d827de3e6dc1494 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 09:13:09 +0000 Subject: [PATCH 16/17] Bump golang.org/x/net from 0.11.0 to 0.20.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.11.0 to 0.20.0. - [Commits](https://github.com/golang/net/compare/v0.11.0...v0.20.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index a337850..5a3d3e6 100644 --- a/go.mod +++ b/go.mod @@ -6,5 +6,5 @@ require ( github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 github.com/json-iterator/go v1.1.12 github.com/modern-go/reflect2 v1.0.2 - golang.org/x/net v0.11.0 + golang.org/x/net v0.20.0 ) diff --git a/go.sum b/go.sum index 135e3b7..95c8730 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,7 @@ github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 h1:NqugFkGxx1TXSh/pBcU00Y6bljgDPaFdh5MUSeJ7e50= github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68/go.mod h1:6pb/Qy8c+lqua8cFpEy7g39NRRqOWc3rOwAy8m5Y2BY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -9,13 +10,15 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OH github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -23,8 +26,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= -golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -35,18 +38,18 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= From c1f8e32399989763d3d13aede0d5a6f6bb47d825 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 09:16:13 +0000 Subject: [PATCH 17/17] Bump github.com/alibabacloud-go/debug Bumps [github.com/alibabacloud-go/debug](https://github.com/alibabacloud-go/debug) from 0.0.0-20190504072949-9472017b5c68 to 1.0.0. - [Release notes](https://github.com/alibabacloud-go/debug/releases) - [Commits](https://github.com/alibabacloud-go/debug/commits/v1.0.0) --- updated-dependencies: - dependency-name: github.com/alibabacloud-go/debug dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5a3d3e6..27e53f5 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/alibabacloud-go/tea go 1.14 require ( - github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 + github.com/alibabacloud-go/debug v1.0.0 github.com/json-iterator/go v1.1.12 github.com/modern-go/reflect2 v1.0.2 golang.org/x/net v0.20.0 diff --git a/go.sum b/go.sum index 95c8730..5af806b 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 h1:NqugFkGxx1TXSh/pBcU00Y6bljgDPaFdh5MUSeJ7e50= -github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68/go.mod h1:6pb/Qy8c+lqua8cFpEy7g39NRRqOWc3rOwAy8m5Y2BY= +github.com/alibabacloud-go/debug v1.0.0 h1:3eIEQWfay1fB24PQIEzXAswlVJtdQok8f3EVN5VrBnA= +github.com/alibabacloud-go/debug v1.0.0/go.mod h1:8gfgZCCAC3+SCzjWtY053FrOcd4/qlH6IHTI4QyICOc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=