First look for config file with extension and only after fallback to no extension

This commit is contained in:
Pedro Silva 2019-11-06 10:50:06 +00:00
parent 895aadc1d8
commit 1107623164
No known key found for this signature in database
GPG key ID: 135E84A1E585EE34

View file

@ -1873,10 +1873,6 @@ func (v *Viper) getConfigFile() (string, error) {
func (v *Viper) searchInPath(in string) (filename string) {
jww.DEBUG.Println("Searching for config in ", in)
if b, _ := exists(v.fs, filepath.Join(in, v.configName)); b {
return filepath.Join(in, v.configName)
}
for _, ext := range SupportedExts {
jww.DEBUG.Println("Checking for", filepath.Join(in, v.configName+"."+ext))
if b, _ := exists(v.fs, filepath.Join(in, v.configName+"."+ext)); b {
@ -1885,6 +1881,10 @@ func (v *Viper) searchInPath(in string) (filename string) {
}
}
if b, _ := exists(v.fs, filepath.Join(in, v.configName)); b {
return filepath.Join(in, v.configName)
}
return ""
}