From 1107623164f1bff2b5f336465925b7342044e98c Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Wed, 6 Nov 2019 10:50:06 +0000 Subject: [PATCH] First look for config file with extension and only after fallback to no extension --- viper.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/viper.go b/viper.go index 5bdf524..c64094a 100644 --- a/viper.go +++ b/viper.go @@ -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 "" }