-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: math: fixed decimal types #68272
Comments
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
We want to avoid the trap of continually revisiting old decisions. That can easily consume all of our time and make it difficult to move forward. Is there significant new information on this topic that would lead us to make a different decision this time? |
The impetus for opening this was noticing that a package my employer depends on heavily at the moment (shopspring/decimal) seems to be semi-abandoned as it's now actively pointing at forks. The previous proposals rely on the existence of these tools in the community as part of the justification for exclusion from the language. Primitive decimal math is something that deserves a higher level of support for interoperability, security and long term stability. |
rsc's comment (from 2016) when #12127 was closed: #12127 (comment) . FWIW https://pkg.go.dev/github.com/shopspring/decimal?tab=importedby lists 34,460 known importers. |
In my opinion, shopspring/decimal hasn't been the most optimal* decimal implementation in the ecosystem for many years now. Projects should be looking to migrate to https://github.com/cockroachdb/apd * - in terms of performance and correctness |
I think this highlights the problem of something so fundamental being relegated to library support - we are forever stuck with a fragmented ecosystem for solutions that traditionally rely on fixed decimal (e.g. finance). |
I'm here for this proposal. That Go doesn't have a native type for decimals is IMHO a deficiency of the language. Claiming that "yeah, but there's non-native packages" is an acceptance of a shortcoming of a type critical for any measurement or financial use case. IMHO this #19787 would be the optimal spot for the discussion (and has it earmarked for Go v2, whenever that may be delivered) |
#19787 (which is no longer marked v2) is about decimal float types, this issue is about decimal fixed types. |
Good catch (v2)! And 🤦🏼 on my behalf. |
Proposal Details
I propose reconsidering the inclusion of fixed decimal types as a standard language feature.
This has been extensively discussed in these two issues:
Motivation
Currently, fixed decimal types are supported by several third-party packages, including the popular shopspring/decimal. However, a recent PR suggests that the long-term maintenance of this library is uncertain. This situation forces the community to constantly adapt to the latest maintained fork, which is a long-term burden on the ecosystem.
Decimal libraries are also crucial in various core areas, such as database drivers, validation, and testing libraries. Standardization of a fixed decimal type would ensure that:
For these reasons I think it is a worth another look at one of the above proposals or a suitable alternative that supports standards and furthers interoperability.
The text was updated successfully, but these errors were encountered: