Skip to content

protoc-gen-go: avoid importing own package #95

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

Closed
wants to merge 1 commit into from
Closed

protoc-gen-go: avoid importing own package #95

wants to merge 1 commit into from

Conversation

abhishekrai
Copy link

Normally, protoc-gen-go recommends certain conventions to avoid
cyclic imports between generated go files. Some of these are
documented in:
#67

This change adds one more mechanism to avoid cycles: if protoc-gen-go
was invoked with import_path parameter set, then it will not generate
import statements for any packages with identical import_path.

This ends up being a simple way of avoiding cycles when all other
options are hard to implement. For example, the codebase that I'm
working with has 100s of proto files shared between code written in
4 different languages including go. It's difficult for us to pass
all proto files in a directory to protoc. Other alternatives
documented in the above issue are even more complex for us to adopt.

In contrast, import_path is easy to set.

Normally, protoc-gen-go recommends certain conventions to avoid
cyclic imports between generated go files.  Some of these are
documented in:
#67

This change adds one more mechanism to avoid cycles: if protoc-gen-go
was invoked with import_path parameter set, then it will not generate
import statements for any packages with identical import_path.

This ends up being a simple way of avoiding cycles when all other
options are hard to implement.  For example, the codebase that I'm
working with has 100s of proto files shared between code written in
4 different languages including go.  It's difficult for us to pass
all proto files in a directory to protoc.  Other alternatives
documented in the above issue are even more complex for us to adopt.

In contrast, import_path is easy to set.
@googlebot
Copy link
Collaborator

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. 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, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@abhishekrai abhishekrai closed this Nov 7, 2015
@golang golang locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants