stevenroose/gonfig

Conf.ConfigFileVariable doesn't support 'short:' option

costela opened this issue · 1 comments

Setting the short: struct tag on the config element referred to by ConfigFileVariable is currently a noop. Currently the docs are unclear about this little gotcha.

E.g.: using something like:

var conf = &struct{
    ConfPath string `id:"confpath" short:"c"`
}{}

gonfig.Load(&conf, gonfig.Conf{
        ConfigFileVariable:  "confpath",
})

And then calling go run . -c /some/file will generate no errors, since the -c flag is recognized, but its value is ignored when searching the actual config file.

I suspect this is something we can work around in lookupConfigFileFlag() (maybe just naively check flagsMap[configOpt.short]?) but it just wasn't enough of an itch for me to scratch. So I'm leaving the issue here until either I get around to it, or someone else beats me to it! 😉

Cheers

Aha, good catch! Yeah that shouldn't be that hard a fix. Might give it a look next time I'm using gonfig myself. Thanks for reporting!