Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error for required env vars with alt name #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wfernandes
Copy link

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 #199

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"`
}
```
@mgerasimchuk
Copy link

@kelseyhightower please have a look

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

Would be great to merge it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error message from required field should include prefix if specified.
3 participants