This commit is contained in:
amone 2024-06-14 13:47:34 +00:00 committed by GitHub
commit df93238c7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

13
file.go
View file

@ -74,6 +74,13 @@ func (v *Viper) findConfigFileOld() (string, error) {
func (v *Viper) searchInPath(in string) (filename string) {
v.logger.Debug("searching for config in path", "path", in)
if v.configType != "" {
if b, _ := exists(v.fs, filepath.Join(in, v.configName+"."+v.configType)); b {
v.logger.Debug("found file", "file", filepath.Join(in, v.configName+"."+v.configType))
return filepath.Join(in, v.configName+"."+v.configType)
}
}
for _, ext := range SupportedExts {
v.logger.Debug("checking if file exists", "file", filepath.Join(in, v.configName+"."+ext))
if b, _ := exists(v.fs, filepath.Join(in, v.configName+"."+ext)); b {
@ -82,12 +89,6 @@ func (v *Viper) searchInPath(in string) (filename string) {
}
}
if v.configType != "" {
if b, _ := exists(v.fs, filepath.Join(in, v.configName)); b {
return filepath.Join(in, v.configName)
}
}
return ""
}