File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ type redisSetting struct {
1818 Host string `short:"H" long:"host" default:"localhost" description:"Hostname"`
1919 Socket string `short:"s" long:"socket" default:"" description:"Server socket"`
2020 Port string `short:"p" long:"port" default:"6379" description:"Port"`
21+ Username string `short:"U" long:"username" default:"" description:"Username"`
2122 Password string `short:"P" long:"password" default:"" description:"Password"`
2223 Timeout uint64 `short:"t" long:"timeout" default:"5" description:"Dial Timeout in sec"`
2324}
@@ -77,7 +78,13 @@ func connectRedis(m redisSetting) (redis.Conn, error) {
7778 }
7879
7980 if password != "" {
80- _ , err := c .Do ("AUTH" , password )
81+ var authArgs []interface {}
82+ if m .Username != "" {
83+ authArgs = []interface {}{m .Username , password }
84+ } else {
85+ authArgs = []interface {}{password }
86+ }
87+ _ , err := c .Do ("AUTH" , authArgs ... )
8188 if err != nil {
8289 return nil , fmt .Errorf ("couldn't authenticate: %v" , err )
8390 }
You can’t perform that action at this time.
0 commit comments