mirror of https://github.com/spf13/viper.git
chore(viper): adding a warning when read file method returns an error and filename contains the extension
This commit is contained in:
parent
15738813a0
commit
70f0ec38dd
7
viper.go
7
viper.go
|
@ -1149,6 +1149,13 @@ func (v *Viper) ReadInConfig() error {
|
||||||
jww.DEBUG.Println("Reading file: ", filename)
|
jww.DEBUG.Println("Reading file: ", filename)
|
||||||
file, err := afero.ReadFile(v.fs, filename)
|
file, err := afero.ReadFile(v.fs, filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fileExt := filepath.Ext(filename)
|
||||||
|
|
||||||
|
if stringInSlice(fileExt, SupportedExts) {
|
||||||
|
log.Println("warning:", "Looks like you have included the file extention in the file name." +
|
||||||
|
"Consider using SetConfigType method instead.")
|
||||||
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue