kelseyhightower / envconfig

Golang library for managing configuration data from environment variables
MIT License
5.02k stars 377 forks source link

Variables with an override don't play nice with logs from Usage and Process #90

Open cv711 opened 7 years ago

cv711 commented 7 years ago

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

teepark commented 7 years ago

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 :)

TonyPythoneer commented 5 years ago

@cv711 Please read README.md. There is sufficient information to resolve your question.

@teepark This issue should get closed.

ronniel1 commented 4 years ago

@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?