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

Error message from required field should include prefix if specified. #199

Open
wfernandes opened this issue Nov 23, 2021 · 1 comment · May be fixed by #200
Open

Error message from required field should include prefix if specified. #199

wfernandes opened this issue Nov 23, 2021 · 1 comment · May be fixed by #200

Comments

@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 environment variable being looked up.

# With prefix configured as "env_config", the variable being looked up is "ENV_CONFIG_BAR".
type Spec struct {
  Foo string `envconfig:"bar" required:"true"`
}

Currently, the error message being reported is required key BAR missing value.
It should be required key ENV_CONFIG_BAR missing value since that's the variable being looked up.

@wfernandes wfernandes linked a pull request Nov 23, 2021 that will close this issue
@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 a pull request may close this issue.

2 participants