Ai
1 Star 0 Fork 0

nggs/micro

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
config.go 979 Bytes
Copy Edit Raw Blame History
李文建 authored 2020-04-04 21:04 +08:00 . 移植microservice的代码
package cluster
import (
"encoding/json"
"fmt"
"io/ioutil"
)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const GlobalConfigName = "global"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
type IGlobalConfig interface {
Check() error
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
type EtcdConfig struct {
Endpoint string
Root string
}
func (cfg *EtcdConfig) Load(path string) error {
data, err := ioutil.ReadFile(path)
if err != nil {
return err
}
err = json.Unmarshal(data, &cfg)
if err != nil {
return err
}
return nil
}
func (cfg EtcdConfig) Check() error {
if cfg.Endpoint == "" {
return fmt.Errorf("Etcd.Endpoint must not empty")
}
if cfg.Root == "" {
return fmt.Errorf("Etcd.Root must not empty")
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/nggs/micro.git
git@gitee.com:nggs/micro.git
nggs
micro
micro
bac99dff65eb

Search