mirror of
https://github.com/redis/go-redis.git
synced 2025-07-18 00:20:57 +03:00
chore: set the default value for the options.protocol
in the init()
of options
(#3387)
* chore: set the default value for the `options.protocol` in the `init()` of `options` Signed-off-by: fukua95 <fukua95@gmail.com> * add a test Signed-off-by: fukua95 <fukua95@gmail.com> --------- Signed-off-by: fukua95 <fukua95@gmail.com>
This commit is contained in:
8
redis.go
8
redis.go
@ -302,15 +302,9 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
|
||||
conn := newConn(c.opt, connPool)
|
||||
|
||||
var auth bool
|
||||
protocol := c.opt.Protocol
|
||||
// By default, use RESP3 in current version.
|
||||
if protocol < 2 {
|
||||
protocol = 3
|
||||
}
|
||||
|
||||
// for redis-server versions that do not support the HELLO command,
|
||||
// RESP2 will continue to be used.
|
||||
if err = conn.Hello(ctx, protocol, username, password, c.opt.ClientName).Err(); err == nil {
|
||||
if err = conn.Hello(ctx, c.opt.Protocol, username, password, c.opt.ClientName).Err(); err == nil {
|
||||
auth = true
|
||||
} else if !isRedisError(err) {
|
||||
// When the server responds with the RESP protocol and the result is not a normal
|
||||
|
Reference in New Issue
Block a user