This commit is contained in:
amone 2024-05-14 18:15:41 +02:00 committed by GitHub
commit ac03520fea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

13
file.go
View file

@ -26,6 +26,13 @@ func (v *Viper) findConfigFile() (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 {
@ -34,12 +41,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 ""
}