From d92dd3019bc3f5f46ee52039587093a07a1596b5 Mon Sep 17 00:00:00 2001 From: Tom Grennan Date: Tue, 7 Jun 2016 11:50:43 -0700 Subject: [PATCH] don't overwrite addr of unix proto if non-empty Signed-off-by: Tom Grennan --- server.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/server.go b/server.go index a691ad0..4f1b4dc 100644 --- a/server.go +++ b/server.go @@ -16,8 +16,9 @@ import ( type Server struct { sync.Mutex - Proto string - Addr string // TCP address to listen on, ":6389" if empty + Proto string // default, "tcp" + Addr string // default, + // if Proto == unix then "/tmp/redis.sock" else ":6389" MonitorChans []chan string methods map[string]HandlerFn listener net.Listener @@ -28,10 +29,12 @@ func (srv *Server) listen() error { if srv.Proto == "" { srv.Proto = "tcp" } - if srv.Proto == "unix" && addr == "" { - addr = "/tmp/redis.sock" - } else if addr == "" { - addr = ":6389" + if addr == "" { + if srv.Proto == "unix" { + addr = "/tmp/redis.sock" + } else { + addr = ":6389" + } } l, e := net.Listen(srv.Proto, addr) if e != nil {