mirror of
https://github.com/spf13/viper
synced 2024-12-22 11:37:02 +00:00
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
1 changed files with 7 additions and 0 deletions
7
viper.go
7
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue