grpc / grpc-go

The Go language implementation of gRPC. HTTP/2 based RPC
https://grpc.io
Apache License 2.0
20.55k stars 4.29k forks source link

Is there a way to separate the protoc-gen-go-grpc code and protoc-gen-go code's directory(=package) ? #4789

Closed take closed 2 years ago

take commented 2 years ago

Hi thanks for the awesome library!

I'm trying to implement a system using grpc + layered architecture and it would be awesome if I can execute the following command

$   protoc --go_out=./domain/models/grpc --go_opt=paths=source_relative \
           --go-grpc_out=./infra/external_api/grpc_gen --go-grpc_opt=paths=source_relative \
           --proto_path=./proto

usually we pass the same value to --go_out and --go-grpc_out, but since

it would be awesome to generate those code to a different layer(directory)

Although if I execute the command above, build will fail since the generated code in the implementation of client/server does not import the messages/serialization properly.

Is there a way to solve this problem?(e.g. pass and import option to the --go-grpc_opt command so the generated code will import the message/serialization properly)

Or we always have to pass the same value to --go_out and --go-grpc_out no matter what?

Thanks,

take commented 2 years ago

I'm sorry this was possible if I set the go_package option correctly