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

时间:2018-05-16 14:32:26

标签: protocol-buffers google-cloud-endpoints grpc google-cloud-endpoints-v2

我尝试部署需要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:. \

来自proto文件的相关位,需要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;
}

尝试了数小时未能成功解决此问题。提前谢谢!

1 个答案:

答案 0 :(得分:3)

在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:. \