mirror of https://github.com/spf13/viper.git
Update viper_go1_15.go
If i have two config file in the same path, one's type is yaml and another is toml. But i set the type: `viper.SetConfigType("yaml")`, old viper_go1_15.go will return me the toml's config. Now the bug is fixed.
This commit is contained in:
parent
343434eb50
commit
ff657bbec2
|
@ -27,6 +27,13 @@ func (v *Viper) findConfigFile() (string, error) {
|
||||||
|
|
||||||
func (v *Viper) searchInPath(in string) (filename string) {
|
func (v *Viper) searchInPath(in string) (filename string) {
|
||||||
v.logger.Debug("searching for config in path", "path", in)
|
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 {
|
for _, ext := range SupportedExts {
|
||||||
v.logger.Debug("checking if file exists", "file", filepath.Join(in, v.configName+"."+ext))
|
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 {
|
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 ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue