From b6d2a925297e3e516eb5c76c114c1c9fcd5b68c5 Mon Sep 17 00:00:00 2001 From: Back Yu Date: Fri, 10 Jun 2022 21:19:02 +0800 Subject: [PATCH] fix: #2114 for redis-server not support Hello Using `strings.HasPrefix` instead of `equal` --- redis.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/redis.go b/redis.go index d292d938..ecc79848 100644 --- a/redis.go +++ b/redis.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "strings" "sync/atomic" "time" @@ -228,11 +229,11 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error { var auth bool - // For redis-server <6.0 that does not support the Hello command, + // For redis-server < 6.0 that does not support the Hello command, // we continue to provide services with RESP2. if err := conn.Hello(ctx, 3, username, password, "").Err(); err == nil { auth = true - } else if err.Error() != "ERR unknown command 'hello'" { + } else if !strings.HasPrefix(err.Error(), "ERR unknown command") { return err }