我的方法以这种格式注册当前时间now = time.Now().format(time.RFC3339)我想把它分配给message.LastReadAt = &now // field LastReadAt *time.Time`example:"2020-05-01T15:00:00Z"` of Message type但是当我尝试“message.LastReadAt = &now”时收到此消息Cannot use '&now' (type *string) as type *time.Time如何将变量“now”转换回“*time.Time”类型?
1 回答
白衣染霜花
TA贡献1796条经验 获得超10个赞
我同意Sheshnath。看起来您需要使用time.Parse https://golang.org/pkg/time/#Parse。
由于您已经指定了格式,time.RFC3339在您使用 时time.Now(),您应该能够做到
t, _ := time.Parse(time.RFC3339, now) message.LastReadAt = t
- 1 回答
- 0 关注
- 178 浏览
添加回答
举报
0/150
提交
取消
