protoc-gen-go: avoid importing own package #95
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.