From 623ec5da1eb04ab23ab8fc5f881d0a4e9f61db2c Mon Sep 17 00:00:00 2001 From: kenshin Date: Tue, 25 Jun 2013 17:00:18 +0800 Subject: [PATCH] Finish redis auth re-commit @shxsun's code. recover previous formation convinient for merge. --- redis.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/redis.go b/redis.go index 68c1a57..fcbce8e 100644 --- a/redis.go +++ b/redis.go @@ -168,6 +168,15 @@ func (client *Client) openConnection() (c net.Conn, err error) { if err != nil { return } + + //handle authentication here authored by @shxsun + if client.Password != "" { + cmd := fmt.Sprintf("AUTH %s\r\n", client.Password) + _, err = client.rawSend(c, []byte(cmd)) + if err != nil { + return + } + } if client.Db != 0 { cmd := fmt.Sprintf("SELECT %d\r\n", client.Db) @@ -176,7 +185,6 @@ func (client *Client) openConnection() (c net.Conn, err error) { return } } - //TODO: handle authentication here return }