-
Notifications
You must be signed in to change notification settings - Fork 145
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
Proposal: Add function NewFromFloat #108
Comments
Hi @npinochet, great idea! I would love to see it implemented, I cannot find any issues with your code example |
Perfect, I went ahead and made the PR #115 |
Hi @Rhymond, first of all thank you so much for this great package! |
Hey @azlancpool, Thanks! I just reviewed a PR and left couple of comments, if you're interested in |
@azlancpool NewFromFloat merged and released in v1.0.9 |
As this issue is only for NewFromFloat, I'll close the issue since it's done 👍 |
It would be really useful to be able to create a new Money struct from a float or maybe a decimal string ('1.243'). Formatting the decimal amount from a source (API response, file, ...) to a Money struct can get really tedious, that's why I propose a util function inside the money package for dealing with this cases.
This is my current implementation:
To not lose precision dealing with floats there can also be a NewFromString, but I haven gotten around to implementing it.
What do you guys think?
The text was updated successfully, but these errors were encountered: