Featured image

It is no secret that you shouldn’t use the float type when working with finances, as it’s crucial not to lose the ultimate precision of the amount during monetary operations. But what surprises me most about Golang is that a language primarily used in fintech lacks a native Decimal type. To compensate for this, you have to opt for third-party solutions. As far as I understand, one of the most popular packages is decimal. I am, of course, aware of math/big, and in some of my simple pet projects, I might use big.Int, even though it’s inconvenient. But for serious production stuff, you’d agree that it’s much better to rely on high-precision decimal numbers implemented in a built-in package rather than a third-party one. And these excuses from the maintainers regarding adding this functionality to the Go standard library look very strange, considering that the decimal type is supported out of the box even in languages like Python, Ruby, and Java.

How do you handle large decimal numbers in your Golang projects? Which third-party libraries do you use: currency, go-money, or maybe apd? Or do you still stick to the built-in big.Int? Would you like to see big.Decimal finally added to Golang?