-
Notifications
You must be signed in to change notification settings - Fork 149
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
1.18 Generics #103
base: master
Are you sure you want to change the base?
1.18 Generics #103
Conversation
Hold up, you are not restricting type anywhere. Users may pass say float64, and loose the main benefit of this library — decimal integer arithmetics. If adding generics, please restrict only to integer types. Also, lots of enterprise code is not migrated to 1.18 yet. By enforcing 1.18 (breaking change?) lots of people can not use this library anymore. Please make new version or advise how this library still can be used with 1.13. Generics are nice, but afraid would be dangerous for this project. |
Hi @nikolaydubina type Numeric interface {
~int | ~int8 | ~int16 | ~int32 | ~int64
} It only allows different types of At the start I was thinking to roll up a new major version, but it looks like that existing tests are all passing fine, which means there are no breaking changes. There are still work needed to be done in regards to custom json marshalling. |
@nikolaydubina Additionally, is a money based on "int8" useful? |
The benefit is that it is not possible to pass float types. One of selling points for go-money is numerical precision, which is gone once floats are used internally.
yes
not really, unless you running on some special hardware. but then likely you would be using C instead But then again, please check with project owner to align on this! :) |
Add 1.18 generics to go-money to allow working with different numeric types of Money (e.g. int, int64)