From a5fe1f32db5eece3d7bd19698b2e5a260b6d2dbb Mon Sep 17 00:00:00 2001 From: lzf Date: Thu, 20 Jun 2024 11:00:14 +0800 Subject: [PATCH] update --- mycrypto/hash.go => hash.go | 2 +- myconf/conf.go | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) rename mycrypto/hash.go => hash.go (96%) diff --git a/mycrypto/hash.go b/hash.go similarity index 96% rename from mycrypto/hash.go rename to hash.go index 33283ad..9d20653 100644 --- a/mycrypto/hash.go +++ b/hash.go @@ -1,4 +1,4 @@ -package mycrypto +package mycommon import ( "crypto/md5" diff --git a/myconf/conf.go b/myconf/conf.go index cb81df8..f217400 100644 --- a/myconf/conf.go +++ b/myconf/conf.go @@ -5,15 +5,24 @@ import ( "github.com/spf13/viper" ) +var ( + vp *viper.Viper +) + func Init(confPath string, conf interface{}) { - v := viper.New() - v.SetConfigFile(confPath) - err := v.ReadInConfig() + vp = viper.New() + vp.SetConfigFile(confPath) + err := vp.ReadInConfig() if err != nil { panic(fmt.Errorf("读取配置文件失败 %s", err)) } - err = v.Unmarshal(conf) + + err = vp.Unmarshal(conf) if err != nil { panic(fmt.Errorf("解析配置文件失败 %s", err)) } } + +func Conf() *viper.Viper { + return vp +}