diff --git a/viper_go1_15.go b/viper_go1_15.go index 19a771c..11397a1 100644 --- a/viper_go1_15.go +++ b/viper_go1_15.go @@ -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 "" }