-
Notifications
You must be signed in to change notification settings - Fork 385
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
Envconfig not respecting Prefix #148
Comments
Hi @jakubdyszkiewicz In general, it's not possible. |
Well... it is possible. Take a look: Complete sample code:
terminal output
|
It's wired. It's because CI is the role of neutral referee. If we have any issue happens in personal computer, the best solution is to add more test for this repo. |
@jakubdyszkiewicz I ran into a similar issue and while investigating I found this is specifically triggered when using the I believe this is the intended behavior based on this note in the README:
|
Here's a playground snippet demonstrating the difference: https://play.golang.org/p/KssTfMgXED1
output:
|
Same problem here. |
Hi. I think this PR is the complete solution. |
…fix and partially saved backward compatibility by using new tag no_pfx
I realized that there is no way to fix this problem without partial backward compatibility break. This wrong (IMHO) behavior is the author's decision (it's obvious if you look at the unit tests). |
with respecting of env-prefix and partially saved backward compatibility by using new tag no_pfx
with respecting of env-prefix and partially saved backward compatibility by using new tag no_pfx
Consider such struct
I'd expect that if
MY_APP_USER
env is not set, thesomething.User
will be empty, but that's not the case. Due to this line https://github.com/kelseyhightower/envconfig/blob/master/envconfig.go#L99 theAlt
is set touser
.Process
method https://github.com/kelseyhightower/envconfig/blob/master/envconfig.go#L195 first try to find byKey
(which isMY_APP_USER
), but then byAlt
, so whenMY_APP_USER
is not available, then theUSER
is looked up. On MacOSUSER
this is set to your username, so instead of empty string I see my username.Is this expected behaviour?
The text was updated successfully, but these errors were encountered: