You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ifb, _:=exists(v.fs, filepath.Join(in, v.configName)); b {
returnfilepath.Join(in, v.configName)
}
}
return""
}
So, if I have a .json file and .yaml file in the same directory, it will read the json as it comes first in the supported extensions list.
Even though it checks whether the extension is supported or not, it just ignores that file with the specified file type.
So, it will use configuration.json over configuration.yml for the following scenario.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Viper version: v1.18.1
Golang Version: go1.21.4 darwin/arm64
Okay, I have read #1408 and it solves the problem.
But going through the code I can see
Viper prepares the filename and checks the file type to see if the type is supported or not.
viper/viper.go
Lines 1623 to 1630 in 0b0a110
When preparing the filename, it checks in the order the
SupportedExts
is defined.viper/file.go
Lines 27 to 44 in 0b0a110
So, if I have a .json file and .yaml file in the same directory, it will read the json as it comes first in the supported extensions list.
Even though it checks whether the extension is supported or not, it just ignores that file with the specified file type.
So, it will use configuration.json over configuration.yml for the following scenario.
Files:
Maybe this check is done for
SetConfigFile
.viper/viper.go
Lines 1628 to 1630 in 0b0a110
Maybe you can suggest
viper.SupportedExts = []string{"yaml", "yml"}
or maybe I am wrong!But can't it be done to use the specified type without this tweak?
TIA.
Beta Was this translation helpful? Give feedback.
All reactions