Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the generated gateway to import the generated protobuf package #353

Open
alltom opened this issue Apr 8, 2017 · 6 comments
Open

Comments

@alltom
Copy link

alltom commented Apr 8, 2017

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?

@alltom alltom changed the title Must generate reverse proxy in same namespace? Must generate reverse proxy in same package? Apr 8, 2017
@achew22
Copy link
Collaborator

achew22 commented Apr 10, 2017

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!

@achew22 achew22 closed this as completed Apr 10, 2017
@fengye87
Copy link

fengye87 commented Aug 2, 2019

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!

@johanbrandhorst
Copy link
Collaborator

johanbrandhorst commented Aug 2, 2019

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 johanbrandhorst changed the title Must generate reverse proxy in same package? Allow the generated gateway to import the proto package Aug 2, 2019
@fengye87
Copy link

fengye87 commented Aug 5, 2019

@johanbrandhorst Glad to know the situation here. I could give it a shot, but no promises 😅

@stale
Copy link

stale bot commented Oct 4, 2019

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.

@stale stale bot added the wontfix label Oct 4, 2019
@stale stale bot closed this as completed Oct 11, 2019
@johanbrandhorst
Copy link
Collaborator

This is still something users want

@stale stale bot removed the wontfix label Apr 16, 2020
@johanbrandhorst johanbrandhorst changed the title Allow the generated gateway to import the proto package Allow the generated gateway to import the generated protobuf package Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants