-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add default values #8
Conversation
this will split a tag on a || and use the value following the pipes (if any) as a default value if none of the env var options return a value
Hi @jimmykodes, thanks for the PR! I see that you decided to pick Could you change this so it follows this convention, and allows more options in the future? I'd like to see: |
Also looks pretty similar to: #5 |
@hinshun Thanks for the feedback! I've updated things to use I've chosen to handle While i'm here, if you have any other extra tag behaviors you'd like to see added, i'd be happy to take a crack at them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very close 👍. Actually, for json struct tags json:",omitempty"
is how they disambiguate between the field name and options. I would prefer env:",required"
to match this convention.
That solves the ambiguity for a single value, but does not solve a case like this: A possible alternate solution i see would be to structure tags like either way, lemme know what you would prefer. |
You're right, I haven't thought of the multiple env keys. Let's just stick with your current implementation then. |
This will allow specifying a default value to be used in the case that none of the key options are found in the env.