From d030c7027756db53c28670a1dd7eb1bcd26ac421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20=C3=81ngel?= Date: Sat, 31 Mar 2018 00:03:06 +0200 Subject: [PATCH] update cmd/fdns to not initialize http.Client if it's not needed --- cmd/fdns.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/cmd/fdns.go b/cmd/fdns.go index cda7355..10adeb3 100644 --- a/cmd/fdns.go +++ b/cmd/fdns.go @@ -48,24 +48,24 @@ func main() { } }() - client := &http.Client{ - CheckRedirect: func(req *http.Request, via []*http.Request) error { - return http.ErrUseLastResponse - }, - Timeout: 15 * time.Second, - Transport: &http.Transport{ - TLSHandshakeTimeout: 15 * time.Second, - ResponseHeaderTimeout: 16 * time.Second, - MaxIdleConnsPerHost: 15, - DisableKeepAlives: false, - MaxIdleConns: 100, - IdleConnTimeout: 16 * time.Second, - ExpectContinueTimeout: 1 * time.Second, - }, - } - var r io.Reader if *url != "" { + client := &http.Client{ + CheckRedirect: func(req *http.Request, via []*http.Request) error { + return http.ErrUseLastResponse + }, + Timeout: 15 * time.Second, + Transport: &http.Transport{ + TLSHandshakeTimeout: 15 * time.Second, + ResponseHeaderTimeout: 16 * time.Second, + MaxIdleConnsPerHost: 15, + DisableKeepAlives: false, + MaxIdleConns: 100, + IdleConnTimeout: 16 * time.Second, + ExpectContinueTimeout: 1 * time.Second, + }, + } + req, err := http.NewRequest("GET", *url, nil) if err != nil { log.Fatalf("could not create request: %v", err)