This commit is contained in:
XYZ0901 2023-09-14 23:40:44 -04:00 committed by GitHub
commit 6e83c66c22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,6 +27,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 != "" && stringInSlice(v.configType,SupportedExts) {
if b, _ := exists(v.fs, filepath.Join(in, v.configName)); b {
return filepath.Join(in, v.configName)
}
}
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 {
@ -35,12 +42,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 ""
}