protoc 生成定义服务的.pd.go,一直失败
1. 运行环境
2. 问题描述?
因为最近在学习GRPC
我想通过protoc 将 Protocol Buffers 编写的 .proto 文件编译成相应go源文件,
当我使用service定义服务时,一直生成不了完整的go源文件
生成命令:
protoc --proto_path=. --go_out=. --go_opt=Mhelloworld.proto=. ./helloworld.proto
syntax = "proto3";//固定写法
package helloworld;
option go_package="./";
/*
写一个服务器的存根
*/
service Hello{
//rpc:远程的接口是什么(Hello接口),参数用message;这是一个接口而已,没有主要内容,主要内容由服务端写
rpc Hello(HelloRequest) returns(Response);
}
message HelloRequest{
string name = 1;//1是编号不是值,注意int类型不支持,只能是int32 或 int64
int32 age =2;
repeated string coursec= 3; //repeated代表这个值是切片可重复
}
message Response{
string reply = 1;
}
3. 您期望得到的结果?
想知道我错误的地方在哪里或者能提供一些思路
4. 您实际得到的结果?
未生成对应的接口
--go_out=.
只是生成编解码protobuf
的文件,grpc
需添加--go-grpc_out=.
,如下: