Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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
SupportedExtsis 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