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

detecting import paths is incorrect for root vanity imports #280

Closed
marwan-at-work opened this issue Oct 11, 2020 · 2 comments · Fixed by #288
Closed

detecting import paths is incorrect for root vanity imports #280

marwan-at-work opened this issue Oct 11, 2020 · 2 comments · Fixed by #288

Comments

@marwan-at-work
Copy link
Contributor

Perhaps the comment in this line of code describes the issue best:

// The presence of a slash implies there's an import path.

An import path may not actually have a slash in it. For example if you define a vanity import such as "go.mycompany.com" and then define your protobuf file at the root of the module as such:

syntax = "proto3";
package mycompany;
option go_package = "go.mycompany.com;mycompany";

...

Twirp will end up generating the following Go package declaration:

package go_mycompany_com_mycompany

...

This is clearly incorrect. Twirp should instead see if there's a semi-colon in the go_package option and then return the left hand side as the import path and the right hand side as the package name.

@amcohen-twitch
Copy link
Contributor

Hi @marwan-at-work, thanks for bringing this to our attention. Our team was unaware of this expected behavior, and are having trouble finding documentation of it. By any chance, could you point us to any further details/docs?

@marwan-at-work
Copy link
Contributor Author

@amcohen-twitch if try to generate Go code with --go_out=. with the latest protoc-gen-go (v2) and notice the warning it will spit out:

2020/11/22 16:42:07 WARNING: Missing 'go_package' option in "dbregistry.proto",
please specify it with the full Go package path as
a future release of protoc-gen-go will require this be specified.
See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.

So the docs it refers to is here: https://developers.google.com/protocol-buffers/docs/reference/go-generated#package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants