Merge pull request #952 from mingrammer/default-addr

Support default redis address
This commit is contained in:
Vladimir Mihailenco 2019-01-13 14:07:05 +02:00 committed by GitHub
commit ce19d9c402
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -24,7 +24,7 @@ func init() {
func ExampleNewClient() { func ExampleNewClient() {
redisdb := redis.NewClient(&redis.Options{ redisdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379", Addr: "localhost:6379", // use default Addr
Password: "", // no password set Password: "", // no password set
DB: 0, // use default DB DB: 0, // use default DB
}) })

View File

@ -101,6 +101,9 @@ func (opt *Options) init() {
if opt.Network == "" { if opt.Network == "" {
opt.Network = "tcp" opt.Network = "tcp"
} }
if opt.Addr == "" {
opt.Addr = "localhost:6379"
}
if opt.Dialer == nil { if opt.Dialer == nil {
opt.Dialer = func() (net.Conn, error) { opt.Dialer = func() (net.Conn, error) {
netDialer := &net.Dialer{ netDialer := &net.Dialer{