Go to file
jordi fita mas 60f9792e58 Convert from cents to “price” and back
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.
2023-02-05 13:55:12 +01:00
cmd/numerus Implement login cookie, its verification, and logout 2023-01-17 20:58:13 +01:00
debian Replace default router with github.com/julienschmidt/httprouter 2023-02-03 12:30:56 +01:00
demo Add sample contacts to the demo 2023-02-03 14:16:46 +01:00
deploy Convert from cents to “price” and back 2023-02-05 13:55:12 +01:00
pkg Convert from cents to “price” and back 2023-02-05 13:55:12 +01:00
po Add products section 2023-02-04 11:32:39 +01:00
revert Convert from cents to “price” and back 2023-02-05 13:55:12 +01:00
test Convert from cents to “price” and back 2023-02-05 13:55:12 +01:00
verify Convert from cents to “price” and back 2023-02-05 13:55:12 +01:00
web Convert from cents to “price” and back 2023-02-05 13:55:12 +01:00
.gitignore Ignore IntelliJ’s project files 2023-01-30 16:42:15 +01:00
COPYING Rename LICENSE to COPYING 2023-01-15 04:08:35 +01:00
Makefile Rename extension of templates to .gohtml 2023-01-30 16:48:21 +01:00
go.mod Replace default router with github.com/julienschmidt/httprouter 2023-02-03 12:30:56 +01:00
go.sum Replace default router with github.com/julienschmidt/httprouter 2023-02-03 12:30:56 +01:00
sqitch.conf Setup authentication schema and user relation 2023-01-13 20:30:21 +01:00
sqitch.plan Convert from cents to “price” and back 2023-02-05 13:55:12 +01:00