我的方法以這種格式注冊當前時間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 關注
- 150 瀏覽
添加回答
舉報
0/150
提交
取消