修改consul Init过程
This commit is contained in:
parent
e3f6f58a7f
commit
abf81b2cc9
|
|
@ -13,9 +13,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_client *consulapi.Client
|
_client *consulapi.Client
|
||||||
conf *Config = &Config{
|
conf *Config
|
||||||
Address: "127.0.0.1:8500",
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
|
@ -25,9 +23,14 @@ type Config struct {
|
||||||
//Init 初始化consul连接
|
//Init 初始化consul连接
|
||||||
func Init(config *Config) error {
|
func Init(config *Config) error {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
return errors.New("config 空实例")
|
conf = &Config{
|
||||||
|
Address: "127.0.0.1:8500",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
conf = config
|
conf = config
|
||||||
|
if conf.Address == "" {
|
||||||
|
conf.Address = "127.0.0.1:8500"
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue