protobuf-3 - 如何在protobuf 3中存储时间

标签 protobuf-3

我在 golang 中有这个结构

struct File {
  name string
  creatation_time time.Time
}

我如何在 protobuf3 中编写它?

最佳答案

创建example.proto;

syntax = "proto3";

import google_protobuf "github.com/golang/protobuf/ptypes/timestamp"

message File {
    string name = 1;
    google.protobuf.Timestamp creatation_time = 2;  
}

编译后检查 example.pb.go 中已创建的结构定义。

关于protobuf-3 - 如何在protobuf 3中存储时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42385281/

相关文章:

python-3.x - Protobuf 和 Python : How to add messages to "repeatable Any" field?

java - 使用多种类型的数据包实现 Protobuf3 的最佳方法是什么?

c# - 在 C#/.NET 中使用 protobuf3 发送通用数据类型的正确方法

python - Python Protobuf 中高效的消息字段设置

regex - Protobuf3 : String validation with regex

go - 如何在 protobuf3 中存储 time.duration

python - 如何在 Protobuf 中序列化嵌套消息中的默认值

python-3.x - 在python中反序列化Protobuf 3 bytearray