gcloud 端点部署错误未解决类型

gcloud endpoints deploy error unresolved type

我正在尝试部署需要 google protobuf's Timestamp 的服务,但我收到错误消息。

gcloud endpoints services deploy api_descriptor.pb api_config.yaml --validate-only

ERROR: (gcloud.endpoints.services.deploy) INVALID_ARGUMENT: Cannot 
convert to service config.
'ERROR: unknown location: Unresolved type '.google.protobuf.Timestamp''

我的命令生成 api_descriptor.pb:

protoc \
--plugin=protoc-gen-go=${GOBIN}/protoc-gen-go \
-I . proto/service.proto \
--descriptor_set_out=api_descriptor.pb \
--go_out=plugins=grpc:. \

原始文件中的相关位需要 google.protobuf.Timestamp:

syntax = "proto3";

package proto;

import "vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto";

message CandleStick {
    string ID = 1;
    double Open = 2;
    double Close = 3;
    double High = 4;
    double Low = 5;

    google.protobuf.Timestamp TimeStamp = 6;
}

已尝试数小时未能解决此问题。提前致谢!

在您的 protoc 命令行调用中,我认为您需要在生成的描述符中包含所有导入。您可以使用 --include_imports:

protoc \
--plugin=protoc-gen-go=${GOBIN}/protoc-gen-go \
--include_imports \
-I . proto/service.proto \
--descriptor_set_out=api_descriptor.pb \
--go_out=plugins=grpc:. \