update
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
package mycrypto
|
package mycommon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
@@ -5,15 +5,24 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
vp *viper.Viper
|
||||||
|
)
|
||||||
|
|
||||||
func Init(confPath string, conf interface{}) {
|
func Init(confPath string, conf interface{}) {
|
||||||
v := viper.New()
|
vp = viper.New()
|
||||||
v.SetConfigFile(confPath)
|
vp.SetConfigFile(confPath)
|
||||||
err := v.ReadInConfig()
|
err := vp.ReadInConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("读取配置文件失败 %s", err))
|
panic(fmt.Errorf("读取配置文件失败 %s", err))
|
||||||
}
|
}
|
||||||
err = v.Unmarshal(conf)
|
|
||||||
|
err = vp.Unmarshal(conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("解析配置文件失败 %s", err))
|
panic(fmt.Errorf("解析配置文件失败 %s", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Conf() *viper.Viper {
|
||||||
|
return vp
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user