Skip to content

Commit b0afaee

Browse files
authored
Merge pull request #33 from yohayg/feature/con-with-username
conn with username
2 parents 4dd4738 + 6674561 commit b0afaee

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

redisconn/conn.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ type Opts struct {
3939
DB int
4040
// Password for AUTH
4141
Password string
42+
// Username for AUTH
43+
Username string
4244
// IOTimeout - timeout on read/write to socket.
4345
// If IOTimeout == 0, then it is set to 1 second
4446
// If IOTimeout < 0, then timeout is disabled
@@ -556,7 +558,9 @@ func (conn *Connection) dial() error {
556558

557559
// Password request
558560
var req []byte
559-
if conn.opts.Password != "" {
561+
if conn.opts.Password != "" && conn.opts.Username != "" {
562+
req, _ = redis.AppendRequest(req, redis.Req("AUTH", conn.opts.Username, conn.opts.Password))
563+
} else if conn.opts.Password != "" {
560564
req, _ = redis.AppendRequest(req, redis.Req("AUTH", conn.opts.Password))
561565
}
562566
const pingReq = "*1\r\n$4\r\nPING\r\n"

0 commit comments

Comments
 (0)