增加配置文件路径 + 配置文件注册
This commit is contained in:
parent
7a68e8e4b9
commit
50c54a9340
4
init.go
4
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
|
||||
|
Loading…
Reference in New Issue
Block a user