Skip to content

Commit 1a9fbe3

Browse files
authored
chore: update dependencies (#28)
* chore: update depenmdencies - replace `github.com/pkg/errors` with stdlib `errors` - replace `github.com/tj/assert` with `github.com/stretchr/testify` * update workflow go version
1 parent 6a52e01 commit 1a9fbe3

File tree

5 files changed

+22
-32
lines changed

5 files changed

+22
-32
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
fail-fast: false
88
matrix:
99
os: [ "ubuntu" ]
10-
go: [ "1.18.x", "1.19.x" ]
10+
go: [ "1.22.x", "1.23.x" ]
1111
env:
1212
COVERAGES: ""
1313
runs-on: ${{ matrix.os }}-latest

go.mod

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ module github.com/ipfs/go-ipfs-redirects-file
33
go 1.22
44

55
require (
6-
github.com/pkg/errors v0.9.1
7-
github.com/tj/assert v0.0.3
6+
github.com/stretchr/testify v1.9.0
87
github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb
98
)
109

1110
require (
1211
github.com/davecgh/go-spew v1.1.1 // indirect
1312
github.com/pmezard/go-difflib v1.0.0 // indirect
14-
github.com/stretchr/testify v1.6.1 // indirect
15-
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c // indirect
13+
gopkg.in/yaml.v3 v3.0.1 // indirect
1614
)

go.sum

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
21
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
32
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
5-
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
63
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
74
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
8-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
9-
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
10-
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
11-
github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk=
12-
github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk=
5+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
6+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
137
github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb h1:Ywfo8sUltxogBpFuMOFRrrSifO788kAFxmvVw31PtQQ=
148
github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb/go.mod h1:ikPs9bRWicNw3S7XpJ8sK/smGwU9WcSVU3dy9qahYBM=
159
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1610
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
17-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
18-
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk+323eIUWOmEevy6bDo=
19-
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
11+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
12+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

redirects.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"strconv"
1010
"strings"
1111

12-
"github.com/pkg/errors"
1312
"github.com/ucarion/urlpath"
1413
)
1514

@@ -134,22 +133,22 @@ func Parse(r io.Reader) (rules []Rule, err error) {
134133
// from (must parse as an absolute path)
135134
from, err := parseFrom(fields[0])
136135
if err != nil {
137-
return nil, errors.Wrapf(err, "parsing 'from'")
136+
return nil, fmt.Errorf("parsing 'from': %w", err)
138137
}
139138
rule.From = from
140139

141140
// to (must parse as an absolute path or an URL)
142141
to, err := parseTo(fields[1])
143142
if err != nil {
144-
return nil, errors.Wrapf(err, "parsing 'to'")
143+
return nil, fmt.Errorf("parsing 'to': %w", err)
145144
}
146145
rule.To = to
147146

148147
// status
149148
if len(fields) > 2 {
150149
code, err := parseStatus(fields[2])
151150
if err != nil {
152-
return nil, errors.Wrapf(err, "parsing status %q", fields[2])
151+
return nil, fmt.Errorf("parsing status %q: %w", fields[2], err)
153152
}
154153

155154
rule.Status = code

redirects_test.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
"testing"
99

10-
"github.com/tj/assert"
10+
"github.com/stretchr/testify/require"
1111
)
1212

1313
func TestRuleIsProxy(t *testing.T) {
@@ -17,7 +17,7 @@ func TestRuleIsProxy(t *testing.T) {
1717
To: "/blog/engineering",
1818
}
1919

20-
assert.False(t, r.IsProxy())
20+
require.False(t, r.IsProxy())
2121
})
2222

2323
t.Run("with host", func(t *testing.T) {
@@ -26,7 +26,7 @@ func TestRuleIsProxy(t *testing.T) {
2626
To: "https://site.example.com",
2727
}
2828

29-
assert.True(t, r.IsProxy())
29+
require.True(t, r.IsProxy())
3030
})
3131
}
3232

@@ -38,7 +38,7 @@ func TestRuleIsRewrite(t *testing.T) {
3838
Status: 302,
3939
}
4040

41-
assert.False(t, r.IsRewrite())
41+
require.False(t, r.IsRewrite())
4242
})
4343

4444
t.Run("with 200", func(t *testing.T) {
@@ -48,7 +48,7 @@ func TestRuleIsRewrite(t *testing.T) {
4848
Status: 200,
4949
}
5050

51-
assert.True(t, r.IsRewrite())
51+
require.True(t, r.IsRewrite())
5252
})
5353

5454
t.Run("with 0", func(t *testing.T) {
@@ -57,7 +57,7 @@ func TestRuleIsRewrite(t *testing.T) {
5757
To: "/blog/engineering",
5858
}
5959

60-
assert.False(t, r.IsRewrite())
60+
require.False(t, r.IsRewrite())
6161
})
6262
}
6363

@@ -67,17 +67,17 @@ func TestParse(t *testing.T) {
6767
/home / 301!
6868
`))
6969

70-
assert.Error(t, err)
71-
assert.Contains(t, err.Error(), "forced redirects")
70+
require.Error(t, err)
71+
require.ErrorContains(t, err, "forced redirects")
7272
})
7373

7474
t.Run("with illegal code", func(t *testing.T) {
7575
_, err := Parse(strings.NewReader(`
7676
/home / 42
7777
`))
7878

79-
assert.Error(t, err)
80-
assert.Contains(t, err.Error(), "status code 42 is not supported")
79+
require.Error(t, err)
80+
require.ErrorContains(t, err, "status code 42 is not supported")
8181
})
8282

8383
t.Run("with too large file", func(t *testing.T) {
@@ -95,8 +95,8 @@ func TestParse(t *testing.T) {
9595

9696
_, err := ParseString(text)
9797

98-
assert.Error(t, err)
99-
assert.Contains(t, err.Error(), "redirects file size cannot exceed")
98+
require.Error(t, err)
99+
require.ErrorContains(t, err, "redirects file size cannot exceed")
100100
})
101101
}
102102

0 commit comments

Comments
 (0)