mirror of https://github.com/spf13/viper.git
added a file exists check before reading
This commit is contained in:
parent
2e9148610a
commit
92882dd559
5
viper.go
5
viper.go
|
@ -1642,6 +1642,11 @@ func (v *Viper) ReadInConfig() error {
|
|||
return UnsupportedConfigError(v.getConfigType())
|
||||
}
|
||||
|
||||
fileExist, err := afero.Exists(v.fs, filename)
|
||||
if !fileExist {
|
||||
return ConfigFileNotFoundError{filename, fmt.Sprintf("%s", v.configPaths)}
|
||||
}
|
||||
|
||||
v.logger.Debug("reading file", "file", filename)
|
||||
file, err := afero.ReadFile(v.fs, filename)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue