Skip to content

Commit 999a680

Browse files
authored
Merge pull request #5 from fastbill/go-update
update Go, linter, deps and remove errors pkg
2 parents 3495ab8 + c00ee5f commit 999a680

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
language: go
22

33
go:
4-
- 1.13.x
4+
- 1.15.x
55

66
install:
77
- go mod vendor
8-
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.19.1
8+
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.33.0
99

1010
script:
1111
- go test -race -cover ./...

go.mod

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
module github.com/fastbill/go-request/v2
22

3-
go 1.13
3+
go 1.15
44

55
require (
6-
github.com/davecgh/go-spew v1.1.1 // indirect
7-
github.com/fastbill/go-httperrors/v2 v2.0.0
8-
github.com/pkg/errors v0.8.1
9-
github.com/stretchr/testify v1.3.0
6+
github.com/fastbill/go-httperrors/v2 v2.0.1
7+
github.com/stretchr/testify v1.6.1
8+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
109
)

go.sum

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
22
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
33
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/fastbill/go-httperrors/v2 v2.0.0 h1:kjfmGJkl2JFMXwxBrkWbldB1ctFIPISHTGBTaTBL/V0=
5-
github.com/fastbill/go-httperrors/v2 v2.0.0/go.mod h1:0Jg7Xs67H09XjGpyQndBYTaOTGfyALE0YNVBgW7iy+8=
6-
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
7-
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
4+
github.com/fastbill/go-httperrors/v2 v2.0.1 h1:xNGkGjEEH6TVNvsilVwAaztElS3p6bpH05HyyIzZe1g=
5+
github.com/fastbill/go-httperrors/v2 v2.0.1/go.mod h1:euMbEiWfbXkgQUp4wunua3Aj8bvNuSS7e1LxtzRKZSA=
86
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
97
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
108
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
119
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
12-
github.com/stretchr/testify v1.1.4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
13-
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
14-
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
10+
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
11+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
12+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
13+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
14+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
15+
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
16+
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
17+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
18+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

request.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"time"
1111

1212
"github.com/fastbill/go-httperrors/v2"
13-
"github.com/pkg/errors"
1413
)
1514

1615
// cachedClient is the global client instance.
@@ -55,13 +54,13 @@ type Params struct {
5554
func Do(params Params, responseBody interface{}) (returnErr error) {
5655
req, err := createRequest(params)
5756
if err != nil {
58-
return err
57+
return fmt.Errorf("failed to create request: %w", err)
5958
}
6059

6160
client := selectClient(params.Timeout)
6261
res, err := client.Do(req)
6362
if err != nil {
64-
return errors.Wrap(err, "failed to send request")
63+
return fmt.Errorf("failed to send request: %w", err)
6564
}
6665

6766
defer func() {
@@ -93,7 +92,7 @@ func DoWithStringResponse(params Params) (result string, returnErr error) {
9392
client := selectClient(params.Timeout)
9493
res, err := client.Do(req)
9594
if err != nil {
96-
return "", errors.Wrap(err, "failed to send request")
95+
return "", fmt.Errorf("failed to send request: %w", err)
9796
}
9897

9998
defer func() {
@@ -123,7 +122,7 @@ func createRequest(params Params) (*http.Request, error) {
123122

124123
req, err := http.NewRequest(params.Method, params.URL, reader)
125124
if err != nil {
126-
return nil, errors.Wrap(err, "failed to create request")
125+
return nil, fmt.Errorf("failed to create request: %w", err)
127126
}
128127
req.Header.Set("Accept", "application/json")
129128
req.Header.Set("Content-Type", "application/json")
@@ -165,7 +164,7 @@ func convertToReader(body interface{}) (io.Reader, error) {
165164
buffer := &bytes.Buffer{}
166165
err := json.NewEncoder(buffer).Encode(body)
167166
if err != nil {
168-
return nil, errors.Wrap(err, "failed to parse request body to json")
167+
return nil, fmt.Errorf("failed to parse request body to json: %w", err)
169168
}
170169

171170
return buffer, nil

request_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func TestDoSuccessful(t *testing.T) {
154154

155155
err := Do(params, nil)
156156
if assert.Error(t, err) {
157-
assert.Contains(t, err.Error(), "request canceled")
157+
assert.Contains(t, err.Error(), "Client.Timeout exceeded")
158158
}
159159
})
160160

0 commit comments

Comments
 (0)