From 3924934ea99334fb387272ba80843528d6217501 Mon Sep 17 00:00:00 2001 From: amone-windows <62925104+amone-bit@users.noreply.github.com> Date: Wed, 7 Feb 2024 18:14:53 +0800 Subject: [PATCH] fix: config file search error --- file.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 "" }