-
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
Unclear doc #1777
Comments
👋 Thanks for reporting! A maintainer will take a look at your issue shortly. 👀 In the meantime: We are working on Viper v2 and we would love to hear your thoughts about what you like or don't like about Viper, so we can improve or fix those issues. ⏰ If you have a couple minutes, please take some time and share your thoughts: https://forms.gle/R6faU74qPRPAzchZ9 📣 If you've already given us your feedback, you can still help by spreading the news, https://twitter.com/sagikazarmark/status/1306904078967074816 Thank you! ❤️ |
@jsumners I don't think it's possible with the current implementation. I agree it's confusing, not very well explained and evolved in the wrong way over time. I opened #1795 with a proposal for a better file searching API. Here is how it would work in your case: finder := locafero.Finder{
Paths: []string{".", "$HOME", "/etc/foo"},
Names: []string{".foo", ".foo.yaml", "config.yaml"},
Type: locafero.FileTypeFile,
}
v := viper.New(viper.WithFinder(finder)) The above is still not perfect though since it would allow results like I opened sagikazarmark/locafero#26 to address that. Considering that proposal, here is how it would roughly look like: finder := locafero.AggregateFinders(
locafero.Finder{
Paths: []string{".", "$HOME"},
Names: []string{".foo", ".foo.yaml"},
Type: locafero.FileTypeFile,
},
locafero.Finder{
Paths: []string{"/etc/foo"},
Names: []string{"config.yaml"},
Type: locafero.FileTypeFile,
},
)
v := viper.New(viper.WithFinder(finder)) You could potentially play with supporting multiple file types if you wanted to. What do you think? Would this suffice your needs? (Your feedback would be very helpful as I just started to work on this solution, so I'm looking to validate this new API) |
viper/README.md
Line 144 in 5870123
That line of the readme is a bit confusing. It took navigating the git blame history to find 9cd5712 and reviewing the commit in context for me to understand that it is saying a file named
~/.foo
can be loaded as YAML whenviper.SetConfigType("yaml")
is used.I was looking for a way to support the following file path possibilities:
/etc/foo/config.yaml
$HOME/.foo
$HOME/.foo.yaml
./.foo
./.foo.yaml
It's still not clear to me if I can support that list.
The text was updated successfully, but these errors were encountered: