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

Add support for casting environment variables to standard types. #168

Open
ruseinov opened this issue Dec 11, 2015 · 4 comments
Open

Add support for casting environment variables to standard types. #168

ruseinov opened this issue Dec 11, 2015 · 4 comments

Comments

@ruseinov
Copy link

What could be done is the Env map could be turned to a type and some convenience methods could be added for type casting, to avoid doing .(int) etc.

Something like Env.Int("param_name") or similar.

@ant0ine
Copy link
Owner

ant0ine commented Jan 18, 2016

What would be the benefit over type assertions (eg: .(int)) ? This is the same amount of typing, and type assertions seem more Go-ish.

@ruseinov
Copy link
Author

It's just nicer this way, you get autocomplete for some common types, also ForceType is also nice to have for convenience.

I've stolen this idea from https://godoc.org/github.com/garyburd/redigo/redis#hdr-Reply_Helpers , feel free to browse through it.

@wingyplus
Copy link

I thing the benefit is caller does not assert type itself. Maybe the method can be assert and return zero value when Env cannot assert.

@ruseinov
Copy link
Author

Exactly!

On Wed, Jan 20, 2016 at 11:36 AM Thanabodee Charoenpiriyakij <
[email protected]> wrote:

I thing the benefit is caller does not assert type itself. Maybe the
method can be assert and return zero value when Env cannot assert.


Reply to this email directly or view it on GitHub
#168 (comment)
.

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

No branches or pull requests

3 participants