Skip to content

Commit 90923b3

Browse files
authored
fix: errors.Join requires Go 1.20 or later (#3442)
Signed-off-by: Xiaolong Chen <[email protected]>
1 parent 9c1655e commit 90923b3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

sentinel.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/redis/go-redis/v9/internal"
1717
"github.com/redis/go-redis/v9/internal/pool"
1818
"github.com/redis/go-redis/v9/internal/rand"
19+
"github.com/redis/go-redis/v9/internal/util"
1920
)
2021

2122
//------------------------------------------------------------------------------
@@ -782,7 +783,20 @@ func (c *sentinelFailover) MasterAddr(ctx context.Context) (string, error) {
782783
for err := range errCh {
783784
errs = append(errs, err)
784785
}
785-
return "", fmt.Errorf("redis: all sentinels specified in configuration are unreachable: %w", errors.Join(errs...))
786+
return "", fmt.Errorf("redis: all sentinels specified in configuration are unreachable: %s", joinErrors(errs))
787+
}
788+
789+
func joinErrors(errs []error) string {
790+
if len(errs) == 1 {
791+
return errs[0].Error()
792+
}
793+
794+
b := []byte(errs[0].Error())
795+
for _, err := range errs[1:] {
796+
b = append(b, '\n')
797+
b = append(b, err.Error()...)
798+
}
799+
return util.BytesToString(b)
786800
}
787801

788802
func (c *sentinelFailover) replicaAddrs(ctx context.Context, useDisconnected bool) ([]string, error) {

0 commit comments

Comments
 (0)