-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple config paths doesn't seem to be working #104
Comments
I think what you are describing is a "works as intended" behaviour, as described in the You provide an ordered collection of search paths, where The reason your example works with Hope that makes sense. |
So, the right solution would be to make a directory and put all toml files to that directory and call |
Ok, I tried as you suggested. I have viper.AddConfigPath("./conf/")
viper.AddConfigPath("./messages/") the conf/config.toml variables are detected but again, messages are not found by viper. Any solutions |
If the explanation below is not sufficient then it would be helpful if you can post the new version of the relevant code, config files content, and expected outcomes - similar to the original post. But let's walk through it again. If your new code looks like this: viper.SetConfigType("toml")
viper.SetConfigName("config")
viper.AddConfigPath("./conf")
viper.AddConfigPath("./messages")
messages.SetDefaultLocale("en")
err := viper.ReadInConfig()
if err != nil {
panic(fmt.Errorf("%s\n", err))
}
fmt.Println("messages value", viper.GetString("hello.world"))
fmt.Println("config value http.host", viper.GetString("http.host")) and you have both If you delete the Please, note, that as mentioned in the
|
I finally got it right. I used |
If you still have this problem. Let try using |
I've been using viper with single config path. However, when I add multiple files the second one could not be retrieved. Here's the code;
Here's the output
And one strange error, if I comment out with line
./config.toml
, the output is same!. I think viper is doing some caching and it's not invalidating.The text was updated successfully, but these errors were encountered: