48 Star 107 Fork 11

喵了个咪 / phalgo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
viper.go 776 Bytes
一键复制 编辑 原始数据 按行查看 历史
文振熙 提交于 2016-10-31 16:26 . 增加DES参数获取
// PhalGo-Config
// 使用spf13大神的viper配置文件获取工具作为phalgo的配置文件工具
// 喵了个咪 <wenzhenxi@vip.qq.com> 2016/5/11
// 依赖情况:
// "github.com/spf13/viper"
package phalgo
import (
"github.com/spf13/viper"
"path"
)
var Config *viper.Viper
//初始化配置文件
func NewConfig(filePath string, fileName string) {
Config = viper.New()
Config.WatchConfig()
Config.SetConfigName(fileName)
//filePath支持相对路径和绝对路径 etc:"/a/b" "b" "./b"
if (filePath[:1] != "/"){
Config.AddConfigPath(path.Join(GetPath(),filePath))
}else{
Config.AddConfigPath(filePath)
}
// 找到并读取配置文件并且 处理错误读取配置文件
if err := Config.ReadInConfig(); err != nil {
panic(err)
}
}
Go
1
https://gitee.com/wenzhenxi/phalgo.git
git@gitee.com:wenzhenxi/phalgo.git
wenzhenxi
phalgo
phalgo
master

搜索帮助