grpc-gateway
grpc-gateway copied to clipboard
Allow the generated gateway to import the generated protobuf package
I'd like to keep all the proto files in a separate directory than the code that gets generated from them, but I can't find a way to invoke protoc that doesn't assume the generated code is in the same package. Is it possible?
I didn't actually run this, but I believe when you run the protoc command you have control of the output directory. To pick the example from the README.md,
protoc -I/usr/local/include -I. \
-I$GOPATH/src \
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--grpc-gateway_out=logtostderr=true:. \
path/to/your_service.proto
The line that says --grpc-gateway_out=logtostderr=true:.
has a .
at the end which is a reference to the current directory. I think (again, I didn't test this) you can point it anywhere you want.
Good luck!
Hi, same problem here.
The point of separating PB code from GW code is that, I have other repos acting as this repo's client, and thus need to import PB code. However, I don't want to import anything from GW, since it's irrelevant in client.
I can choose where to generate the gateway code, but it seems that the generated code is expecting itself locates in the same package of the PB code. It uses PB types without any package prefix. Any solution here? Thanks!
In a brief test with some of my own generated files it seems like it might be possible to generate into a separate folder and import all the types and functions. I think we should be able to support this, but I don't know if we want to add the complexity of figuring out imports to the generator, so ideally it would be something we could turn on with a flag and then use via the go_package
option maybe? @fengye87 would you be interested in contributing this new feature?
@johanbrandhorst Glad to know the situation here. I could give it a shot, but no promises :sweat_smile:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This is still something users want