简体   繁体   中英

Protoc protoc-gen-go "timestamp" is not defined

I need to use Protocol Buffers to serialize JSON messages received from the Google Drive drives:list method and write them to the BigQuery Storage Write API (GRPC). This is working for all field types except timestamp. I cannot for the life of me generate go classes that include timestamps. To begin, I'm following this document , although have also tried everything I can find online including here on stackoverflow to no avail.

On MacOS 12.6, protoc is installed from this zip to /usr/local/bin and the contents of include from the zip are installed to /usr/local/include.

This is the drives.proto file I need to create a class for:

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;
  }
}

If I remove the field with type timestamp, the tool creates a file named./driveBuffers/drives.pb.go. With the timestamp type, this error is thrown:

% protoc --go_out=. -I ./ -I /usr/local/include/ drives.proto
drives.proto:11:3: "timestamp" is not defined.

Thank you.

You should refer the type as google.protobuf.Timestamp . As example:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM