mirror of
https://github.com/spf13/viper
synced 2024-12-22 19:47:01 +00:00
fix: config file search error
This commit is contained in:
parent
8f34134e70
commit
3924934ea9
1 changed files with 6 additions and 6 deletions
12
file.go
12
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 ""
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue