go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

A RPC service generated by multiple proto files?

Open liangyuan1 opened this issue 10 months ago • 3 comments

基础proto image 用户proto image 角色proto image 执行命令 goctl rpc protoc basicServices.proto --go_out=./pb --go-grpc_out=./pb --zrpc_out=./basicServices -m

如何基于多个proto文件按照分组的方式生成服务类似api服务那样 image

liangyuan1 avatar Apr 21 '24 10:04 liangyuan1

go-zero 目前应该是不支持你想要的效果。目前我推荐的方式是这样的。比如一个 user.proto, 一个 role.proto 文件。可以使用多个 goctl 命令进行生成,但是会产生一些多余的 etc 配置文件,多余的 main 文件等。在 shell 脚本中进行删除,并在注册 grpc 服务的地方手动注册进去进行了。如果觉得麻烦,可以考虑 Jzero。一个对 go-zero 的封装,可以一键创建项目,一键生成代码。支持多 proto 分组等特性。项目地址:https://github.com/jaronnie/jzero

jaronnie avatar Apr 22 '24 02:04 jaronnie

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


go-zero currently probably does not support the effect you want. The way I currently recommend is this. For example, a user.proto, a role.proto file. Multiple goctl commands can be used for generation, but some redundant etc configuration files, redundant main files, etc. will be generated. Delete it in the shell script and manually register it where the grpc service is registered. If you find it troublesome, you can consider Jzero. A package of go-zero that can create projects and generate code with one click. Supports features such as multi-proto grouping. Project address: https://github.com/jaronnie/jzero

Issues-translate-bot avatar Apr 22 '24 02:04 Issues-translate-bot

The message of rpc service must be defined in the same proto file as the service. Importing from outside is not supported. Please refer to the documentation https://go-zero.dev/docs/tutorials/cli/rpc#goctl-rpc-protoc

kesonan avatar Apr 25 '24 14:04 kesonan