chore(viper): adding a warning when read file method returns an error and filename contains the extension

This commit is contained in:
Afshin Mehrabani 2018-06-16 15:54:37 +01:00
parent 15738813a0
commit 70f0ec38dd

View file

@ -1149,6 +1149,13 @@ func (v *Viper) ReadInConfig() error {
jww.DEBUG.Println("Reading file: ", filename)
file, err := afero.ReadFile(v.fs, filename)
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
}