-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix import alias issue with protoc-gen-grpc-gateway #1757
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
fix import alias issue with protoc-gen-grpc-gateway #1757
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Codecov Report
@@ Coverage Diff @@
## master #1757 +/- ##
==========================================
- Coverage 58.74% 58.73% -0.02%
==========================================
Files 33 33
Lines 3624 3625 +1
==========================================
Hits 2129 2129
- Misses 1237 1238 +1
Partials 258 258
Continue to review full report at Codecov.
|
retain parsing order comment
5fb70cb to
e996ca6
Compare
johanbrandhorst
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix looks fine, and I think it will change in the long term with the work @adambabik is doing in #1756 (:heart:), but I was wondering if we could add a test for this, or a test file that when generated without this fix exhibits the failure?
Thanks again for your contributions!
|
Looks like we'll need to rebase these changes on master since #1752 was merged. |
|
Hi Daniel, I just merged #1756 so this will need a rebase, sorry for the inconvenience. |
|
Thanks for your contribution! |
Have you read the Contributing Guidelines?
Yes
Brief description of what is fixed or changed
Starting in v2, if any base imports collide with imported packages in the proto, the base import will be aliased and
pb.gw.gowill not compile. Compilation fails because the rest of the template does not account for the import alias.Proto file import (whose go_package is google.golang.org/genproto/googleapis/rpc/status):
Generated
batch.pb.gw.go:Build fails.
The regression occurred as part of the move to v2 because the files are loaded into the registry in v2 before the generator set up base imports in the registry.
Other comments
I'm sure there are many possible fixes here. However, I went ahead and just had the registry returned by the generator New instead of being an input parameter to enforce the call order previously used in v1. Happy to try another approach if this is building on a brittle foundation.
(note: working on getting corp CLA signed)