protobuf 导入 google/protobuf/timestamp.proto

protobuf import google/protobuf/timestamp.proto

我的原型文件是:

syntax = "proto3";

import "google/protobuf/timestamp.proto";

service Foo {
  rpc now(NowRequest) returns (NowResponse) {}
}

message NowRequest {}

message NowResponse {
  google.protobuf.Timestamp now = 1;
}

我生成代码的命令和产生的错误是:

protoc foo.proto --go_out=plugins=grpc,import_path=proto:internal/proto
foo.proto:3:1: Import "google/protobuf/timestamp.proto" was not found or had errors.
foo.proto:12:3: "google.protobuf.Timestamp" is not defined.

我的协议版本是:

protoc --version
libprotoc 3.11.3

我已经关注了这个guide and reviewed this question。如何导入众所周知的类型?我还需要下载其他东西吗?我如何知道我当前安装的确切已知类型是什么?谢谢。

"google/protobuf/timestamp.proto" 存储在路径中:/usr/local/include/google/protobuf

请检查您是否有 /usr/local/include/google/protobuf 目录。

如果不是,说明protobuf安装有错误。请追溯所遵循的安装步骤或尝试重新安装。

请在此处找到更多帮助:https://github.com/grpc-ecosystem/grpc-gateway/issues/422