feature: search file
bersace opened this issue · comments
Hi,
Thanks for koanf, it's awesome.
I think it may be useful if file
module provides a helper to find a file amongst candidate. e.g.
path := file.Find(
"ldaprc",
".ldaprc",
"ldap.conf",
)
And also finding a file in parent directory:
path := file.FindParent("docker-compose.yml")
What do you think of this need ?
Regards,
Étienne
Thanks @bersace. Unsure if we should add these as util functions as they only take a couple of lines of code to implement. In the same vein, there may be many other niche util functions that'll then have to be considered. FindRecursively()
etc.
Implementing a Find functionality can be as simple as this for instance.
for _, f := range []string{"ldaprc", ".ldaprc", "ldap.conf"} {
if _, err := os.Stat(filename); err == nil {
k.Load(file.Provider(f), toml.Parser())
break
}
}