1 Star 0 Fork 0

xiedongji / antgo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
config.go 626 Bytes
一键复制 编辑 原始数据 按行查看 历史
xiedongji 提交于 2023-03-22 18:29 . 优化细节
package xcfg
import (
"github.com/spf13/viper"
"os"
)
var config *viper.Viper
func init() {
config = viper.New()
wd, err := os.Getwd()
if err != nil {
panic(err)
}
config.AddConfigPath(wd)
config.SetConfigName("app")
config.SetConfigType("yml")
if err := config.ReadInConfig(); err != nil {
panic(err)
}
}
// 配置读取 二次封装
func Get(key string) interface{} {
return config.Get(key)
}
func GetString(key string) string {
return config.GetString(key)
}
func GetStringSlice(key string) []string {
return config.GetStringSlice(key)
}
func GetInt(key string) int {
return config.GetInt(key)
}
Go
1
https://gitee.com/xiedongji/antgo.git
git@gitee.com:xiedongji/antgo.git
xiedongji
antgo
antgo
v1.0.18

搜索帮助