From 0ecf16e7736ec9e67852e594a67b7ef923fbd425 Mon Sep 17 00:00:00 2001 From: Timothy Yen Date: Tue, 30 Jul 2019 13:03:40 -0700 Subject: [PATCH] Options: Use DialContext by default Use net.Dialer DialContext by default because go-redis supports contexts. Resolves #1101 --- options.go | 2 +- redis_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/options.go b/options.go index 4da74b1..095be5a 100644 --- a/options.go +++ b/options.go @@ -112,7 +112,7 @@ func (opt *Options) init() { KeepAlive: 5 * time.Minute, } if opt.TLSConfig == nil { - return netDialer.Dial(network, addr) + return netDialer.DialContext(ctx, network, addr) } return tls.DialWithDialer(netDialer, opt.Network, opt.Addr, opt.TLSConfig) } diff --git a/redis_test.go b/redis_test.go index eb1bc98..d763380 100644 --- a/redis_test.go +++ b/redis_test.go @@ -51,7 +51,8 @@ var _ = Describe("Client", func() { Network: "tcp", Addr: redisAddr, Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) { - return net.Dial(network, addr) + var d net.Dialer + return d.DialContext(ctx, network, addr) }, })