From d184d958d711a9a57d8ef44a5a09fa30758113bc Mon Sep 17 00:00:00 2001 From: lsytj0413 <511121939@qq.com> Date: Tue, 21 Jul 2020 15:18:36 +0800 Subject: [PATCH] feat(option): default dialtimeout take effect when dialer is nil --- options.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/options.go b/options.go index 68047c6f..90c09450 100644 --- a/options.go +++ b/options.go @@ -120,6 +120,9 @@ func (opt *Options) init() { opt.Network = "tcp" } } + if opt.DialTimeout == 0 { + opt.DialTimeout = 5 * time.Second + } if opt.Dialer == nil { opt.Dialer = func(ctx context.Context, network, addr string) (net.Conn, error) { netDialer := &net.Dialer{ @@ -135,9 +138,6 @@ func (opt *Options) init() { if opt.PoolSize == 0 { opt.PoolSize = 10 * runtime.NumCPU() } - if opt.DialTimeout == 0 { - opt.DialTimeout = 5 * time.Second - } switch opt.ReadTimeout { case -1: opt.ReadTimeout = 0