有没有办法在 Golang 中实现 cassandra "decimal" 数据类型

Is there a way to implement cassandra "decimal" Datatype in Golang

我有一个设置为十进制的数据库字段,而在我的 Go 项目中,我在选择可以使用的数据类型时遇到了问题。 每次我向我的代码发送创建请求时,我都会收到“无法将 'decimal' 编组到 #golang 数据类型#

这是我的数据库架构

CREATE TABLE wage_garnishment(
organization_id timeuuid,
yyyy text,
employee_id timeuuid,
id timeuuid,
employee_name text,
amount decimal,
deductions int,
date_created date,
date_modified date,
date_approved date,
PRIMARY KEY ((organization_id, yyyy), id)

)

我的 golang 模型是这样的

type WageGarnishment struct {
ID            gocql.UUID `json:"id"`
organizationID            gocql.UUID `json:"organization_id"`
Yyyy          string     `json:"yyyy"`
Amount        Float64    `json:"amount"`
Deductions    uint       `json:"deductions"`
EffectiveDate time.Time  `json:"effective_date"`
DateCreated   time.Time  `json:"date_created"`
DateApproved  time.Time  `json:"date_approved"`
DateModified  time.Time  `json:"date_modified"`
EmployeeSummary

}

无论我的金额字段中的数据类型如何,我都会不断收到此错误:

Error #01: can not marshal float64 into decimal

提前感谢您的帮助

如果您查看 documentation for Gocql package, then you will see that the decimal is mapped to the Go's infDec data type (see its doc),那么您需要使用它而不是 Float64