envconfig
envconfig copied to clipboard
Variables with an override don't play nice with logs from Usage and Process
Let's say I define a bunch of variables but one of them has an override e.g.
LogLevel string desc:"Log level override" envconfig:"LOG_LEVEL"
then I would expect that a call to envconfig.Usage("CMD", &cfg)
should print it as LOG_LEVEL ...
, instead of that I get CMD_LOG_LEVEL
.
Same thing seems to be happening with the error from envconfig.Process("CMD", &cfg)
. When missing a required variable with an override I get required key CMD_LOG_LEVEL missing value
as a message.
Thanks, Chris
You're totally right here. I believe the code would accept either <prefix>_<name>
or just <name>
(when tagged with "envconfig"
), but the non-prefixed version should definitely be favored. I'd happily merge a PR that fixed this :)
@cv711 Please read README.md
. There is sufficient information to resolve your question.
@teepark This issue should get closed.
@TonyPythoneer I also need to have the Usage() print the alternate names instead of the key. I looked at the README.md and did not find the info on how to do it. Can you point me in the right direction?