fix: #2114 for redis-server not support Hello

Using `strings.HasPrefix` instead of `equal`
This commit is contained in:
Back Yu 2022-06-10 21:19:02 +08:00 committed by GitHub
parent 4ddd7d1803
commit b6d2a92529
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -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
}