Does GORM have a decimal datatype to store money values (-> Decimal(8,2)
)?
I could not find it on https://github.com/jinzhu/gorm#define-models-structs
Michael's answer works. But If you want to use decimal type with golang, you can use shopspring/decimal like this:
type TableName struct {
Amount decimal.Decimal `json:"amount" sql:"type:decimal(20,8);"`
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With