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