gpt4 book ai didi

go - GORM 是否有 Decimal 数据类型?

转载 作者:IT王子 更新时间:2023-10-29 01:17:37 29 4
gpt4 key购买 nike

是否GORM有十进制数据类型来存储货币值 (-> Decimal(8,2))?

我在 https://github.com/jinzhu/gorm#define-models-structs 上找不到它

最佳答案

Michael 的回答有效。但是如果你想在 golang 中使用 decimal 类型,你可以使用 shopspring/decimal像这样:

type TableName struct {
Amount decimal.Decimal `json:"amount" sql:"type:decimal(20,8);"`
}

关于go - GORM 是否有 Decimal 数据类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28983956/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com