-
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
Support config files with no extensions #722
Support config files with no extensions #722
Conversation
Hi, I really want this, any news when it will be merged ? @pedromss maybe a update of the README is required ? |
@gjrtimmer I don't know what else is required to get this approved. Seems like this repo isn't maintained judging by the state of the PR and issue section ¯_(ツ)_/¯ |
I like this approach as well. |
@pedromss Just for me to understand: you want to explicitly set a config name with an extension? viper.SetConfigNam("config.yaml") And you want to search for that specific file within the configured search paths? Is that correct? |
@sagikazarmark no. The idea is to be able to have configuration files that don't have an extension in their name. As is many times the case with tools which have config files in the home folder for example. So supporting |
@pedromss I see. Thanks for the explanation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a few lines and an example about this feature to the readme? Maybe after the Reading Config Files section.
Apart from that ✔️
@sagikazarmark please take another look now |
Thanks @pedromss ! |
@pedromss actually, I wonder if the condition should be moved after the the loop, to make sure existing behavior isn't broken (eg. there is a config and a config.yaml file in a folder. this PR would break existing code in those cases). WDYT? |
@sagikazarmark I had thought to resolve it immediately without "unnecessarily" walking the files in the folder. But what you say makes more sense. Changed it. |
Awesome, thanks! This is a one time step, so I wouldn't worry about unnecessary checks for non-existing files. |
You're correct 😕 I must have made a mistake when analysing the issue. Reading it again, I would say this comment #390 (comment) made me think the problem was the no extension, which was a problem in it self but not of that issue. Thank you. I'll edit this description and reopen #390 |
Support config files with no extension.
Closes: #390This was a mistakeCloses: #336
Similar to https://github.com/spf13/viper/pull/357/files which appears to have been forgotten.
Difference is: attempt a no extension right away instead of messing with the extension append and iterating through the extensions.