I do not want to use floats in the Go lang application, because it is not supposed to do anything with these values other than to print and retrieve them from the user; all computations will be performed by PostgreSQL in cents. That means i have to “convert” from the price format that users expect to see (e.g., 1.234,56) to cents (e.g., 123456) and back when passing data between Go and PostgreSQL, and that conversion depends on the currency’s decimal places. At first i did everything in Go, but saw that i would need to do it in a loop when retrieving the list of products, and immediately knew it was a mistake—i needed a PL/pgSQL function for that. I still need to convert from string to float, however, when printing the value to the user. Because the string representation is in C, but i need to format it according to the locale with golang/x/text. That package has the information of how to correctly format numbers, but it is in an internal package that i can not use, and numbers.Digit only accepts numeric types, not a string.
Description
v1
Latest
Languages
PLpgSQL
64.2%
Go
21.4%
CSS
11.6%
JavaScript
2%
Scheme
0.7%