1

protoc 文档非常少。我经常看到这样的事情,但我找不到任何文档。

protoc -I routeguide/ routeguide/route_guide.proto --go_out=plugins=grpc:routeguide

  • plugins=grpc: 做什么?需要配合使用 go_out吗?如果是这样,我认为这很令人困惑,因为 go_out据说只是指定了输出目录。

https://github.com/golang/protobuf有这个例子。 protoc --go_out=plugins=grpc,import_path=mypackage:. *.proto

这更令人困惑,因为它有额外import_path的 . 根据文档,plugins=grpc,import_path=mypackage:被认为是附加参数(因为它以 : 结尾)并.表示输出目录。

这是对的吗?plugins=grpc我仍然不知道import_path=mypacakge该做什么。

4

1 回答 1

-1

如何编写原型

syntax = "proto3";

message Request {
    int64 phone_number =1;
}

message Response {
    int64 phone_number = 1;
    string message = 2;
    int32 status_code =3;
}

service CreateService{
    rpc Service (Request) returns (Response);
}

生成代码:

#generate gRPC-Code

protoc oauth2/proto/oauth.proto --go_out=plugins=grpc:.

有关 proto 和 gRPC 的更多信息,这些 repos 包含通过良好示例推进的基本知识

https://github.com/SXerox007/gRPC-Remote-Procedure-Call-

https://github.com/SXerox007/protos-

于 2019-01-28T09:07:27.397 回答