Replace `uber-go/multierr` with `errors.Join` (#10912)
Andrew Gillis committed
Aug 13, 2025 at 02:03 UTC
a3b01cd05ff159c22a909dca841130657c9dbb0f
5 files changed
+15
-15
client/rpc/api_test.go
+2
-2
@@ -2,6 +2,7 @@ package rpc
2
3
import (
4
"context"
5
+ "errors"
6
"net/http"
7
"net/http/httptest"
8
"strconv"
@@ -16,7 +17,6 @@ import (
17
"github.com/ipfs/kubo/core/coreiface/tests"
18
"github.com/ipfs/kubo/test/cli/harness"
19
ma "github.com/multiformats/go-multiaddr"
19
- "go.uber.org/multierr"
20
)
21
22
type NodeProvider struct{}
@@ -91,7 +91,7 @@ func (np NodeProvider) MakeAPISwarm(t *testing.T, ctx context.Context, fullIdent
91
92
wg.Wait()
93
94
- return apis, multierr.Combine(errs...)
94
+ return apis, errors.Join(errs...)
95
}
96
97
func TestHttpApi(t *testing.T) {
cmd/ipfs/kubo/daemon.go
+6
-4
@@ -44,7 +44,6 @@ import (
44
manet "github.com/multiformats/go-multiaddr/net"
45
prometheus "github.com/prometheus/client_golang/prometheus"
46
promauto "github.com/prometheus/client_golang/prometheus/promauto"
47
- "go.uber.org/multierr"
47
)
48
49
const (
@@ -725,14 +724,17 @@ take effect.
724
725
// collect long-running errors and block for shutdown
726
// TODO(cryptix): our fuse currently doesn't follow this pattern for graceful shutdown
728
- var errs error
727
+ var errs []error
728
for err := range merge(apiErrc, gwErrc, gcErrc, p2pGwErrc, pluginErrc, unmountErrc) {
729
if err != nil {
731
- errs = multierr.Append(errs, err)
730
+ errs = append(errs, err)
731
}
732
}
733
+ if len(errs) != 0 {
734
+ return errors.Join(errs...)
735
+ }
736
735
- return errs
737
+ return nil
738
}
739
740
// serveHTTPApi collects options, creates listener, prints status message and starts serving requests.
go.mod
+1
-1
@@ -83,7 +83,6 @@ require (
83
go.opentelemetry.io/otel/trace v1.37.0
84
go.uber.org/dig v1.19.0
85
go.uber.org/fx v1.24.0
86
- go.uber.org/multierr v1.11.0
86
go.uber.org/zap v1.27.0
87
golang.org/x/crypto v0.41.0
88
golang.org/x/exp v0.0.0-20250811191247-51f88131bc50
@@ -247,6 +246,7 @@ require (
246
go.opentelemetry.io/otel/metric v1.37.0 // indirect
247
go.opentelemetry.io/proto/otlp v1.7.0 // indirect
248
go.uber.org/mock v0.5.2 // indirect
249
+ go.uber.org/multierr v1.11.0 // indirect
250
go.uber.org/zap/exp v0.3.0 // indirect
251
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
252
golang.org/x/net v0.43.0 // indirect
repo/fsrepo/migrations/fetcher.go
+5
-6
@@ -2,11 +2,10 @@ package migrations
2
3
import (
4
"context"
5
+ "errors"
6
"fmt"
7
"io"
8
"os"
8
-
9
- "go.uber.org/multierr"
9
)
10
11
const (
@@ -49,23 +48,23 @@ func NewMultiFetcher(f ...Fetcher) *MultiFetcher {
48
49
// Fetch attempts to fetch the file at each of its fetchers until one succeeds.
50
func (f *MultiFetcher) Fetch(ctx context.Context, ipfsPath string) ([]byte, error) {
52
- var errs error
51
+ var errs []error
52
for _, fetcher := range f.fetchers {
53
out, err := fetcher.Fetch(ctx, ipfsPath)
54
if err == nil {
55
return out, nil
56
}
57
fmt.Printf("Error fetching: %s\n", err.Error())
59
- errs = multierr.Append(errs, err)
58
+ errs = append(errs, err)
59
}
61
- return nil, errs
60
+ return nil, errors.Join(errs...)
61
}
62
63
func (f *MultiFetcher) Close() error {
64
var errs error
65
for _, fetcher := range f.fetchers {
66
if err := fetcher.Close(); err != nil {
68
- errs = multierr.Append(errs, err)
67
+ errs = errors.Join(errs, err)
68
}
69
}
70
return errs
routing/composer.go
+1
-2
@@ -9,7 +9,6 @@ import (
9
"github.com/libp2p/go-libp2p/core/peer"
10
"github.com/libp2p/go-libp2p/core/routing"
11
"github.com/multiformats/go-multihash"
12
- "go.uber.org/multierr"
12
)
13
14
var (
@@ -124,7 +123,7 @@ func (c *Composer) Bootstrap(ctx context.Context) error {
123
errgv := c.GetValueRouter.Bootstrap(ctx)
124
errpv := c.PutValueRouter.Bootstrap(ctx)
125
errp := c.ProvideRouter.Bootstrap(ctx)
127
- err := multierr.Combine(errfp, errfps, errgv, errpv, errp)
126
+ err := errors.Join(errfp, errfps, errgv, errpv, errp)
127
if err != nil {
128
log.Debug("composer: calling bootstrap error: ", err)
129
}