go-micro 简单读取配置文件
在根目录下创建配置文件(config/config.json)
{
"name": "hello",
"etcd": {
"address": ["127.0.0.1:2379"]
}
}
引入包
"github.com/micro/go-micro/config"
"github.com/micro/go-micro/config/source/file"
在main中使用
type Cfg struct {
Name string
Etcd struct{
.
原创
2020-09-24 08:23:46 ·
527 阅读 ·
0 评论