我创建了这样的表:
CREATE TABLE MyTable
(
id uuid,
Test BOOLEAN NOT NULL,
end_date TIMESTAMP NULL DEFAULT NULL,
PRIMARY KEY (id)
);
我的结构
type Issue struct {
ID uuid.UUID
Test bool
EndDate time.Time `db:"due_date"`
}
现在的情况是有一些日期没有在实时数据库中,所以现在我查询得到我得到这个错误EndDateall data
ERROR: sql: Scan error on column index 11, name "i.end_date": unsupported Scan, storing driver.Value type <nil> into type *time.Time
我不知道问题在哪里。
更新
如果我使用sql。NullTime,然后我做了一个像这样的反击模式
return &model.Issue{
AssetOwnerID: id,
DueDate : time.Now().UTC().Truncate(time.Second)
}
我收到此错误
Cannot use 'time.Now().UTC().Truncate(time.Second)' (type Time) as type sql.NullTime
www说
相关分类