【问题标题】:Golang: How to Convert time.Time to a Protobuf Timestamp?Golang:如何将 time.Time 转换为 Protobuf 时间戳?
【发布时间】:2021-12-17 11:33:43
【问题描述】:

我在 Golang 10-30 00:49:07.1236 中有一个 time.Time 变量,需要转换为 Go Protobuf timestamp.Timestamp。关于可以使用哪些功能来完成此任务的任何想法?还是我从错误的角度看这个?

【问题讨论】:

标签: go timestamp protocol-buffers unix-timestamp


【解决方案1】:

参见timestamppb 中的NewTimestamp.AsTime

这些支持与time.TimeTimestamp 之间的转换

【讨论】:

    猜你喜欢
    • 2017-10-10
    • 2019-08-02
    • 2014-09-19
    • 2019-05-21
    • 2016-04-15
    • 2019-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多