This commit is contained in:
2023-01-15 00:21:08 +08:00
commit 0fdfb59809
15 changed files with 1374 additions and 0 deletions

19
myconf/conf.go Normal file
View File

@@ -0,0 +1,19 @@
package myconf
import (
"fmt"
"github.com/spf13/viper"
)
func Init(confPath string, conf interface{}) {
v := viper.New()
v.SetConfigFile(confPath)
err := v.ReadInConfig()
if err != nil {
panic(fmt.Errorf("读取配置文件失败 %s", err))
}
err = v.Unmarshal(conf)
if err != nil {
panic(fmt.Errorf("解析配置文件失败 %s", err))
}
}