1 Star 1 Fork 0

007lz / go-tinyid

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
config.go 586 Bytes
一键复制 编辑 原始数据 按行查看 历史
lizhen 提交于 2023-10-30 15:35 . 代码框架搭建
package config
import (
"fmt"
"sync"
"github.com/spf13/viper"
)
var Viper = viper.New()
var once = &sync.Once{}
func Init(path string) {
once.Do(func() {
Viper.SetConfigName("mysql")
Viper.SetConfigType("toml")
Viper.AddConfigPath(path)
if err := Viper.ReadInConfig(); err != nil {
panic(fmt.Errorf("err is (%w)", err))
}
for _, config := range Viper.GetStringSlice("include.configs") {
Viper.SetConfigName(config)
if err := Viper.MergeInConfig(); err != nil {
panic(fmt.Errorf("err is (%w)", err))
}
}
fmt.Println("config init success!")
})
}
Go
1
https://gitee.com/git-lz/go-tinyid.git
git@gitee.com:git-lz/go-tinyid.git
git-lz
go-tinyid
go-tinyid
v0.0.1

搜索帮助