Skip to content

Commit

Permalink
chore: update dependencies and replace github.com/pkg/errors
Browse files Browse the repository at this point in the history
- Update dependencies
- Replace `github.com/pkg/errors` dependency with native error wrapping. The package `github.com/pkg/errors` is now in maintenance mode due to the existence of golang native error wrapping.
  - convert `errors.Wrapf(err, "… %s: %s", foo, bar)` to `fmt.Errorf("… %s: %s: %w", foo, bar err)` and check that `err != nil` before
  • Loading branch information
gammazero committed Oct 21, 2024
1 parent 6870a88 commit 78ac5c5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
9 changes: 5 additions & 4 deletions commands/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import (
"path"
"time"

"github.com/pkg/errors"
cli "github.com/urfave/cli"

"github.com/ipfs/iptb/testbed"
cli "github.com/urfave/cli"
)

var ConnectCmd = cli.Command{
Expand Down Expand Up @@ -130,11 +128,14 @@ func connectNodes(tb testbed.BasicTestbed, from, to []int, timeout time.Duration
defer cancel()

err = nodes[f].Connect(ctx, nodes[t])
if err != nil {
err = fmt.Errorf("node[%d] => node[%d]: %w", f, t, err)
}

Check warning on line 133 in commands/connect.go

View check run for this annotation

Codecov / codecov/patch

commands/connect.go#L131-L133

Added lines #L131 - L133 were not covered by tests

results = append(results, Result{
Node: f,
Output: nil,
Error: errors.Wrapf(err, "node[%d] => node[%d]", f, t),
Error: err,

Check warning on line 138 in commands/connect.go

View check run for this annotation

Codecov / codecov/patch

commands/connect.go#L138

Added line #L138 was not covered by tests
})
}
}
Expand Down
6 changes: 4 additions & 2 deletions commands/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"sync"

testbedi "github.com/ipfs/iptb/testbed/interfaces"
"github.com/pkg/errors"
cli "github.com/urfave/cli"
)

Expand Down Expand Up @@ -184,14 +183,17 @@ func mapWithOutput(list []int, nodes []testbedi.Core, fn outputFunc) ([]Result,
go func(i, n int, node testbedi.Core) {
defer wg.Done()
out, err := fn(node)
if err != nil {
err = fmt.Errorf("node[%d]: %w", n, err)
}

Check warning on line 188 in commands/utils.go

View check run for this annotation

Codecov / codecov/patch

commands/utils.go#L186-L188

Added lines #L186 - L188 were not covered by tests

lk.Lock()
defer lk.Unlock()

results[i] = Result{
Node: n,
Output: out,
Error: errors.Wrapf(err, "node[%d]", n),
Error: err,

Check warning on line 196 in commands/utils.go

View check run for this annotation

Codecov / codecov/patch

commands/utils.go#L196

Added line #L196 was not covered by tests
}
}(i, n, nodes[n])
}
Expand Down
10 changes: 7 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
module github.com/ipfs/iptb

require (
github.com/mattn/go-shellwords v1.0.5
github.com/pkg/errors v0.8.1
github.com/urfave/cli v1.20.0
github.com/mattn/go-shellwords v1.0.12
github.com/urfave/cli v1.22.16
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
)

go 1.22
34 changes: 28 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
github.com/mattn/go-shellwords v1.0.5 h1:JhhFTIOslh5ZsPrpa3Wdg8bF0WI3b44EMblmU9wIsXc=
github.com/mattn/go-shellwords v1.0.5/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc=
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
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/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk=
github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
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/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli v1.22.16 h1:MH0k6uJxdwdeWQTwhSO42Pwr4YLrNLwBtg1MRgTqPdQ=
github.com/urfave/cli v1.22.16/go.mod h1:EeJR6BKodywf4zciqrdw6hpCPk68JO9z5LazXZMn5Po=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit 78ac5c5

Please sign in to comment.