我需要使用协议缓冲区来序列化从Google Drive Drives:List方法接收的JSON消息,并将它们写入BigQuery存储写入API(GRPC).这适用于除TIMESTAMP之外的所有字段类型.我无论如何都不能生成包含时间戳的围棋类.首先,我关注了this document个,虽然我也try 了所有我能在网上找到的东西,包括这里的Stackoverflow,但都没有用.
在MacOS 12.6上,Protoc从this zip安装到/usr/local/bin,压缩包中的Include内容安装到/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;
}
}
如果我删除类型为TIMESTAMP的字段,该工具将创建一个名为./driveBuffers/drives.pb.go的文件.对于TIMESTAMP类型,抛出以下错误:
% protoc --go_out=. -I ./ -I /usr/local/include/ drives.proto
drives.proto:11:3: "timestamp" is not defined.
谢谢.