为了账号安全,请及时绑定邮箱和手机立即绑定

Protoc protoc-gen-go“时间戳”未定义

Protoc protoc-gen-go“时间戳”未定义

Go
函数式编程 2023-02-14 17:58:38
我需要使用 Protocol Buffers 序列化从 Google Drive drives:list 方法接收的 JSON 消息,并将它们写入 BigQuery Storage Write API (GRPC)。这适用于除时间戳之外的所有字段类型。我终生无法生成包含时间戳的 go 类。首先,我正在关注此文档,尽管我也尝试了我可以在网上找到的所有内容,包括在 stackoverflow 上的此处,但都无济于事。在 MacOS 12.6 上,protoc 从此zip安装到 /usr/local/bin,zip 中包含的内容安装到 /usr/local/include。这是我需要创建一个类的 drives.proto 文件:syntax = "proto3";option go_package = "./driveBuffers";import "google/protobuf/timestamp.proto";message Drive {  string id =1;  string name =2;  string colorRgb = 3;  string backgroundImageLink =4;  bool hidden = 5;  string orgUnitId = 6;  timestamp createdTime = 7;  message restrictions {    bool adminManagedRestrictions = 1;    bool domainUsersOnly = 2;    bool copyRequiresWriterPermission = 3;    bool driveMembersOnly = 4;  }}如果我删除时间戳类型的字段,该工具会创建一个名为 ./driveBuffers/drives.pb.go 的文件。使用时间戳类型,会抛出这个错误:% protoc --go_out=. -I ./ -I /usr/local/include/ drives.protodrives.proto:11:3: "timestamp" is not defined.
查看完整描述

1 回答

?
慕慕森

TA贡献1856条经验 获得超17个赞

您应该将该类型称为google.protobuf.Timestamp. 例如:

  string orgUnitId = 6;
  google.protobuf.Timestamp createdTime = 7;


查看完整回答
反对 回复 2023-02-14
  • 1 回答
  • 0 关注
  • 104 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信