我的方法以这种格式注册当前时间
now = time.Now().format(time.RFC3339)
我想把它分配给
message.LastReadAt = &now // field LastReadAt *time.Time`example:"2020-05-01T15:00:00Z"` of Message type
但当我试图";消息LastReadAt=&现在";
Cannot use '&now' (type *string) as type *time.Time
如何将变量";现在";回到"*时间时间";类型
我同意Sheshnath的观点。看起来您需要使用time.Parse
https://golang.org/pkg/time/#Parse.
由于您已经在使用time.Now()
时指定了一种格式time.RFC3339
,因此您应该能够进行
t, _ := time.Parse(time.RFC3339, now)
message.LastReadAt = t