diff --git a/file.go b/file.go index a54fe5a..a84cdf4 100644 --- a/file.go +++ b/file.go @@ -26,6 +26,12 @@ 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)); 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 { @@ -34,12 +40,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 "" }