1 Star 0 Fork 0

bugsmo/kratos-bootstrap

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
bootstrap_config.go 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
bugsmo 提交于 2024-06-01 21:56 . v1.0.0
package config
import conf "gitee.com/ssxlt/kratos-bootstrap/api/gen/go/conf/v1"
var configList []interface{}
var commonConfig = &conf.Bootstrap{}
func GetBootstrapConfig() *conf.Bootstrap {
return commonConfig
}
// RegisterConfig 注册配置
func RegisterConfig(c interface{}) {
initBootstrapConfig()
configList = append(configList, c)
}
func initBootstrapConfig() {
if len(configList) > 0 {
return
}
configList = append(configList, commonConfig)
if commonConfig.Server == nil {
commonConfig.Server = &conf.Server{}
configList = append(configList, commonConfig.Server)
}
if commonConfig.Client == nil {
commonConfig.Client = &conf.Client{}
configList = append(configList, commonConfig.Client)
}
if commonConfig.Data == nil {
commonConfig.Data = &conf.Data{}
configList = append(configList, commonConfig.Data)
}
if commonConfig.Trace == nil {
commonConfig.Trace = &conf.Tracer{}
configList = append(configList, commonConfig.Trace)
}
if commonConfig.Logger == nil {
commonConfig.Logger = &conf.Logger{}
configList = append(configList, commonConfig.Logger)
}
if commonConfig.Registry == nil {
commonConfig.Registry = &conf.Registry{}
configList = append(configList, commonConfig.Registry)
}
if commonConfig.Oss == nil {
commonConfig.Oss = &conf.OSS{}
configList = append(configList, commonConfig.Oss)
}
if commonConfig.Notify == nil {
commonConfig.Notify = &conf.Notification{}
configList = append(configList, commonConfig.Notify)
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ssxlt/kratos-bootstrap.git
git@gitee.com:ssxlt/kratos-bootstrap.git
ssxlt
kratos-bootstrap
kratos-bootstrap
v1.0.6

搜索帮助