1 Star 0 Fork 0

曾广宇 / mxx-core-v2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
loader.go 884 Bytes
一键复制 编辑 原始数据 按行查看 历史
曾广宇 提交于 2023-06-20 11:36 . 新增apollo存储配置
package msystem
import (
"fmt"
"github.com/pelletier/go-toml/v2"
"os"
)
var Environment = &EnvironmentModel{}
func InitSystem(environment string, dest ...any) {
switch environment {
case "dev":
LoadConfig("./conf/config-dev.toml", dest...)
break
case "pro":
LoadConfig("./conf/config-pro.toml", dest...)
break
case "fat":
LoadConfig("./conf/config-fat.toml", dest...)
break
case "test":
LoadConfig("./conf/config-test.toml", dest...)
break
default:
panic(fmt.Sprintf("Current environment is [%s] , The environment is incorrect. The following parameters must be used [pro,fat,dev,test]", environment))
}
}
func LoadConfig(path string, dest ...any) {
b, err := os.ReadFile(path)
if err != nil {
panic(err)
}
for i := range dest {
item := dest[i]
if item != nil {
err = toml.Unmarshal(b, item)
if err != nil {
panic(err)
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dennis-mxx/mxx-core-v2.git
git@gitee.com:dennis-mxx/mxx-core-v2.git
dennis-mxx
mxx-core-v2
mxx-core-v2
v0.2.6

搜索帮助

344bd9b3 5694891 D2dac590 5694891