You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: add --client-only flag for goctl rpc protoc to generate only rpc client code #5665
Is your feature request related to a problem? Please describe.
I'm always frustrated when generating gRPC client code for go-zero API gateway. Currently, the goctl rpc protoc command always generates a complete RPC server skeleton, including redundant etc, internal, and service entry files, even if I only need the RPC client for API service invocation.
These extra server files are completely unnecessary for API gateway projects and require manual deletion every time, which is redundant and inefficient for cross-language gRPC invocation scenarios (e.g., calling Python gRPC services registered in etcd).
Describe the solution you'd like
I would like to add a --client-only flag for the goctl rpc protoc command.
When this flag is enabled:
Only generate pb.go, grpc.pb.go and go-zero wrapped rpc client code
Skip generating all server-side code, including etc, internal, service main file and server implementation code
This allows developers to generate clean client code specifically for API gateway consumption.
Describe alternatives you've considered
Manually delete redundant server files after each generation (error-prone and inefficient)
Use pure native protoc command without go-zero client encapsulation (lose go-zero's zrpc capability like service discovery, circuit breaker, load balancing)
No clean and official solution exists for pure client generation right now.
Additional context
In go-zero layered architecture, API services only depend on RPC clients and never host RPC server services. A dedicated client-only generation flag fits the official layered design and greatly improves development experience for microservice gateway scenarios.
I'd like to work on this. The current --client option controls whether the client wrapper is generated, but it does not provide a mode that skips the server skeleton.
I'll add an opt-in --client-only mode to goctl rpc protoc, keeping the default output unchanged and avoiding server-directory creation as well as server templates. I'll cover generation inside an existing Go module, standalone output, multiple services, and imported message types, then compile the generated clients. Combining --client-only with --client=false should fail before creating output files rather than silently producing an incomplete result.
Activity
fzlzjerry commentedon Sep 8, 2026
I'd like to work on this. The current
--clientoption controls whether the client wrapper is generated, but it does not provide a mode that skips the server skeleton.I'll add an opt-in
--client-onlymode togoctl rpc protoc, keeping the default output unchanged and avoiding server-directory creation as well as server templates. I'll cover generation inside an existing Go module, standalone output, multiple services, and imported message types, then compile the generated clients. Combining--client-onlywith--client=falseshould fail before creating output files rather than silently producing an incomplete result.