How to represent currency in Go?

I’d say a way to go is to store amounts of money using properly sized integer type, normalized to the lowest possible amount. Say, if you need to store amounts in US dollars down to one cent, multiply your values by 100 and hence store them in full cents.

Another way is to implement a custom type which would model what is “decimal” in some other languages, that is, it would use two integer numbers to represent amount of money.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)