feat(goctl):support multi-proto to generate rpc servcie and allow proto to import other proto file#5293
feat(goctl):support multi-proto to generate rpc servcie and allow proto to import other proto file#5293gszw90 wants to merge 27 commits intozeromicro:masterfrom
Conversation
- Add --rpc_name flag to set the RPC service name - Update configuration file and main file generation to use the specified service name - Modify README to include new flag description and usage examples - Enhance support for generating code from multiple proto files within the same service
- Add --rpc_name flag to set the RPC service name - Update configuration file and main file generation to use the specified service name - Modify README to include new flag description and usage examples - Enhance support for generating code from multiple proto files within the same service
…at-add-rpc-name # Conflicts: # tools/goctl/internal/flags/default_en.json # tools/goctl/rpc/README.md # tools/goctl/rpc/cli/cli.go # tools/goctl/rpc/cli/zrpc.go # tools/goctl/rpc/cmd.go # tools/goctl/rpc/generator/gen.go # tools/goctl/rpc/generator/genetc.go # tools/goctl/rpc/generator/genmain.go
- Change --rpc_name to --name in the goctl rpc command description
# Conflicts: # tools/goctl/rpc/cli/cli.go # tools/goctl/rpc/cli/zrpc.go # tools/goctl/rpc/cmd.go
|
What problem does this PR need to solve? From the perspective of code changes, it is necessary to support the generation of multiple service protos, but these protos should point to different services. Why do the output directories point to app variables? I don’t think this is a good solution. On the surface, it is to convert scripting into goctl one-time generation, but the complexity of use becomes extremely high. I do not recommend increasing the complexity of use to reduce the code generation workload. |
|
This pr addresses two issues: first, it resolves the problem of file bloat caused by defining multiple services in a single proto file; second, it improves extensibility by referencing another proto file within a single proto file. goctl rpc protoc ./app/pb/role.proto \
--go_out=./app/pb \
--go-grpc_out=./app/pb \
--zrpc_out=./approle.proto syntax = "proto3";
package role;
option go_package = "./role";
message GetRoleRequest {
string role_id = 1;
}
message GetRoleResponse {
string role_id = 1;
string role_name = 2;
}
service RoleService {
rpc GetRole(GetRoleRequest) returns (GetRoleResponse);
} |
|
try jzero? https://docs.jzero.io |
# Conflicts: # tools/goctl/go.mod # tools/goctl/go.sum

support multi-proto to generate rpc servcie and allow proto to import other proto file
here is the directory:
run:
rusult:

commom.proto
role.proto
user.proto
sub.proto