使用protoc编译.proto文件生成go文件

编译

protoc --go_out=plugins=grpc:./helloworld/ ./helloworld.proto 

只会生成一个pb.go文件,既可以作为client也可以作为server。

protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative ./helloworld.proto

在当前目录生成pb.g和grpc.go文件

proto --go_out=. --go-grpc_out=. helloworld.proto

猜你喜欢

转载自blog.csdn.net/ydl1128/article/details/127824559
今日推荐