From d3f447a7321f77366b0fff59d0fb60c90f3b0197 Mon Sep 17 00:00:00 2001 From: shuxian Date: Thu, 28 Feb 2019 09:56:57 +0800 Subject: [PATCH] solve NewRegistry httpclient 'nil pointer dereference' bug --- registry/consul/consul.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/registry/consul/consul.go b/registry/consul/consul.go index 7e9cf794..52b8b2cd 100644 --- a/registry/consul/consul.go +++ b/registry/consul/consul.go @@ -105,12 +105,13 @@ func configure(c *consulRegistry, opts ...registry.Option) { } } + if config.HttpClient == nil { + config.HttpClient = new(http.Client) + } + // requires secure connection? if c.opts.Secure || c.opts.TLSConfig != nil { - if config.HttpClient == nil { - config.HttpClient = new(http.Client) - } - + config.Scheme = "https" // We're going to support InsecureSkipVerify config.HttpClient.Transport = newTransport(c.opts.TLSConfig)