From abf81b2cc9cca071ee33d28b948e5e87c7a4fddc Mon Sep 17 00:00:00 2001 From: "suguo.yao" Date: Wed, 15 Sep 2021 19:00:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9consul=20Init=E8=BF=87?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- consul/consul.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/consul/consul.go b/consul/consul.go index 7d0513a..0d9b789 100644 --- a/consul/consul.go +++ b/consul/consul.go @@ -13,9 +13,7 @@ import ( var ( _client *consulapi.Client - conf *Config = &Config{ - Address: "127.0.0.1:8500", - } + conf *Config ) type Config struct { @@ -25,9 +23,14 @@ type Config struct { //Init 初始化consul连接 func Init(config *Config) error { if config == nil { - return errors.New("config 空实例") + conf = &Config{ + Address: "127.0.0.1:8500", + } } conf = config + if conf.Address == "" { + conf.Address = "127.0.0.1:8500" + } return nil }