admin管理员组

文章数量:1122846

When generating grpc code for protocol buffers. received this error

My .proto file - was following the basic tutorial from the GRPC Docs - GRPC Docs

message Point {
int32 latitude = 1  ;
int32 longitude = 2 ;
}

message Rectangle {
Point lo = 1        ;
Point hi = 2        ;
}

message Feature {
string name = 1    ;
Point location = 2 ;
}

message RouteNote {
Point location = 1  ;
string message = 2  ;
}

message RouteSummary {
int32 point_count = 1   ;
int32 feature_count = 2 ;
int32 distance = 3      ;
int32 elapsed_time = 4  ;
}

service RouteGuide{
rpc GetFeature(Point) returns (Feature) {}
rpc ListFeatures(Rectangle) returns (stream Feature) {}
rpc RecordRoute(stream Point) returns (RouteSummary) {}
rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
}

Received the error

route_guide.proto:5:1: Expected "required", "optional", or "repeated".

When generating grpc code for protocol buffers. received this error

My .proto file - was following the basic tutorial from the GRPC Docs - GRPC Docs

message Point {
int32 latitude = 1  ;
int32 longitude = 2 ;
}

message Rectangle {
Point lo = 1        ;
Point hi = 2        ;
}

message Feature {
string name = 1    ;
Point location = 2 ;
}

message RouteNote {
Point location = 1  ;
string message = 2  ;
}

message RouteSummary {
int32 point_count = 1   ;
int32 feature_count = 2 ;
int32 distance = 3      ;
int32 elapsed_time = 4  ;
}

service RouteGuide{
rpc GetFeature(Point) returns (Feature) {}
rpc ListFeatures(Rectangle) returns (stream Feature) {}
rpc RecordRoute(stream Point) returns (RouteSummary) {}
rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
}

Received the error

route_guide.proto:5:1: Expected "required", "optional", or "repeated".
Share Improve this question asked yesterday Tushar GuptaTushar Gupta 611 silver badge4 bronze badges New contributor Tushar Gupta is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 3

I found an answer after some time. All I needed to do was to specify the .proto syntax I was using with the file

syntax = "proto3";

package routeguide;
option go_package = "/proto";

Read more here

本文标签: