From 70f0ec38dde6c7a2e3ebab56cb350573d487fa14 Mon Sep 17 00:00:00 2001 From: Afshin Mehrabani Date: Sat, 16 Jun 2018 15:54:37 +0100 Subject: [PATCH] chore(viper): adding a warning when read file method returns an error and filename contains the extension --- viper.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/viper.go b/viper.go index 907a102..0d03fa5 100644 --- a/viper.go +++ b/viper.go @@ -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 }