-
Notifications
You must be signed in to change notification settings - Fork 1.6k
.pb.go import error: local import "." in non-local package #67
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
Comments
If |
protoc --go_out=. a.proto I did similar script when i generated cpp files? thanks for your reply |
You haven't told protoc-gen-go how to map |
I did what you told me to do and It works now, thank you very much |
Normally, protoc-gen-go recommends certain conventions to avoid cyclic imports between generated go files. Some of these are documented in: golang#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.
@dsymonds How to use the M parameter? I have two proto files: a.proto with package a and b.proto with package b, a.proto imports b. proto. When compiled with |
If you've got two proto files that are going into the same package (implied by passing them on the command line together), they need to have the same package name. |
Also see #39. |
I wrote some proto files that one import others.
like this:
package myproto;
import "a.proto";
import "b.proto";
import "c.proto";
import "d.proto";
import "e.proto";
these files are all in package myproto;
When I generated pb.go files and import "myproto"
go compiler told:
import cycle not allowed
package .
imports myproto
imports .
imports .
echo.go:5:2: local import "." in non-local package
Is it a bug of protoc-gen-go?
The text was updated successfully, but these errors were encountered: