Skip to content
This repository was archived by the owner on Mar 11, 2020. It is now read-only.

Commit d92dd30

Browse files
committed
don't overwrite addr of unix proto if non-empty
Signed-off-by: Tom Grennan <[email protected]>
1 parent 340ca98 commit d92dd30

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

server.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import (
1616

1717
type Server struct {
1818
sync.Mutex
19-
Proto string
20-
Addr string // TCP address to listen on, ":6389" if empty
19+
Proto string // default, "tcp"
20+
Addr string // default,
21+
// if Proto == unix then "/tmp/redis.sock" else ":6389"
2122
MonitorChans []chan string
2223
methods map[string]HandlerFn
2324
listener net.Listener
@@ -28,10 +29,12 @@ func (srv *Server) listen() error {
2829
if srv.Proto == "" {
2930
srv.Proto = "tcp"
3031
}
31-
if srv.Proto == "unix" && addr == "" {
32-
addr = "/tmp/redis.sock"
33-
} else if addr == "" {
34-
addr = ":6389"
32+
if addr == "" {
33+
if srv.Proto == "unix" {
34+
addr = "/tmp/redis.sock"
35+
} else {
36+
addr = ":6389"
37+
}
3538
}
3639
l, e := net.Listen(srv.Proto, addr)
3740
if e != nil {

0 commit comments

Comments
 (0)