kelseyhightower / envconfig

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

Improve error for required env vars with alt name #200

Open wfernandes opened 2 years ago

wfernandes commented 2 years ago

If we have a prefix called "env_config" and the following struct tags for property "Foo", we should expect to see an error message stating that the required env var "ENV_CONFIG_BAR" is missing and not just "BAR" since that is the env var being looked up.

type Spec struct {
  Foo string `envconfig:"bar" required:"true"`
}

Fixes https://github.com/kelseyhightower/envconfig/issues/199

mgerasimchuk commented 1 year ago

@kelseyhightower please have a look

also faced this problem and @wfernandes solution works totally well for me

Would be great to merge it