From 78d1dfeeca867071ff22e64983de5f845740b1c7 Mon Sep 17 00:00:00 2001 From: iuu <2167162990@qq.com> Date: Mon, 23 Dec 2024 18:43:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/vcs.xml | 6 ++++++ core/viper/viper.go | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/core/viper/viper.go b/core/viper/viper.go index a94b88c..ec45c74 100644 --- a/core/viper/viper.go +++ b/core/viper/viper.go @@ -10,7 +10,6 @@ import ( "os" ) -// InitViper 解析yaml格式文件 func InitViper(path ...string) { var confPath string if len(path) == 0 { @@ -29,17 +28,13 @@ func InitViper(path ...string) { } v := viper.New() - // 指定配置文件路径 v.SetConfigFile(confPath) - // 如果配置文件的名称中没有扩展名,则需要配置此项 v.SetConfigType("yaml") - // 查找并读取配置文件 err := v.ReadInConfig() if err != nil { fmt.Printf("[-]读取配置文件错误: %s \n", err) os.Exit(0) } - // 监控并重新读取配置文件 v.WatchConfig() v.OnConfigChange(func(e fsnotify.Event) { if err = v.Unmarshal(&global.AppConf); err != nil {