Skip to content

Commit

Permalink
Merge pull request redis#952 from mingrammer/default-addr
Browse files Browse the repository at this point in the history
Support default redis address
  • Loading branch information
vmihailenco authored Jan 13, 2019
2 parents d9c8076 + c9fed25 commit ce19d9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ func init() {

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

pong, err := redisdb.Ping().Result()
Expand Down
3 changes: 3 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func (opt *Options) init() {
if opt.Network == "" {
opt.Network = "tcp"
}
if opt.Addr == "" {
opt.Addr = "localhost:6379"
}
if opt.Dialer == nil {
opt.Dialer = func() (net.Conn, error) {
netDialer := &net.Dialer{
Expand Down

0 comments on commit ce19d9c

Please sign in to comment.