From 50c54a93403f1cdd363d3cb30f6dafbc382122a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 7 Nov 2024 18:51:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=B7=AF=E5=BE=84=20+=20=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/init.go b/init.go index c61cbdd..36ba5de 100644 --- a/init.go +++ b/init.go @@ -31,6 +31,10 @@ import ( // - configFilePath 配置文件目录 // - configFileNameList 要加载的配置文件列表 func InitByViper(configReceiver any, envFileList []string, configFilePath string, configFileNameList []string) error { + viper.AddConfigPath(configFilePath) + for _, configFileName := range configFileNameList { + viper.SetConfigName(configFileName) + } // 解析配置 if err := viper.ReadInConfig(); nil != err { return err