Skip to content

feat: add --client-only flag for goctl rpc protoc to generate only rpc client code #5665

Description

@QZ-dolphin

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:

  1. Only generate pb.go, grpc.pb.go and go-zero wrapped rpc client code
  2. 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

  1. Manually delete redundant server files after each generation (error-prone and inefficient)
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions