-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
proposal: protoc-gen-go should be able to compile multiple packages per run #39
Comments
The standard way for Go packages to be distinguished is to be in separate directories. The package declaration in a Go file is not the way that package boundaries are defined; the |
With you so far.
This is where you lost me. That Go demands that a package is made up of files in the same directory is not the same as compiling a single package at a time. Rather, it seems that there's a requirement that each collection of files that belongs to a single package must be located in the same directory. For these files which each belong to a different package:
It should be legal to invoke |
Your last command seems to have been cut off. I'm not saying that |
I understand what you are saying, but you are just describing the status quo. Why is this not a valid use case for protoc-gen-go to support? The exact same use case is supported by the Java code generator. |
See my comment in the pull request. |
so, how to solve the question? now every time I generate code for golang, I need do lots of manual work to fix generated code. |
We use https://github.com/square/goprotowrap - a wrapper that collects things into packages. Pull requests welcome :-) The sad part is that it would be pretty straightforward to make Go protos work like other languages :-( |
@tamird So, has this been fixed or not? I cannot get it work, I have some structures like this:
And under the path
Where am I doing wrong? |
It has not been fixed.
|
What's the status of this bug? Why is this and #67 both closed? I have a number of protos which all depend on one proto declaring a few custom options declared in its own package. If I compile all the protos separately, I run into #67 and running them together I run into this issue. It seems like packaging protos in go is broken then? |
Google doesn't want to fix this:
the most common golang protobuf usability issue is too complex apparently. thanks to Square for providing a practical solution to a real issue. shame on golang protobuf maintainers. |
I'm going through the issue tracker and figuring what needs to be done. Re-opening this so this doesn't get forgotten. This does not necessarily imply it will be implemented as every feature needs to be carefully thought through. |
Pinging this thread for subscribers to see #515. |
I wanted to play with golang and implement one of grpc services in it. Got this error, saw this thread.. This is the fastest turn around that language can provide. |
New year's update:
|
I haven't tried it, but if it does what it sounds like, I doubt using source-relative paths would work for us. We explicitly set the |
Can you clarify what this means? In protobuf, cyclic dependencies are only possible within a proto file. Since each proto file is generated to exactly one Go source file, that should make it impossible to have cyclicly dependent Go packages result from that. |
If You would not have this problem at Google, because you use blaze for building everything, and it can create multiple distinct Go packages in the same directory, based on your BUILD rules. |
If I understand you correctly, you're describing a file tree that looks like:
However, proto-file layout does not necessary correspond with go package layout since the If:
With the
or
then this works. However, both Go package layouts would not work with @zellyn, I'm curious. At a high-level, what modifications to |
Yes, you're describing the problem exactly, and it appears As for modifications… we forked both protoc-gen-go fairly early on, which led to people assuming a freedom to make changes that has made unforking difficult. I'm almost the whole way there. Ignoring ill-thought changes, there are two big/unavoidable ones:
|
One last random thought: that second bullet point (my current arc of unforking work) has been slow because I've been fixing every single place people use Edit: it looks like github.com/google/go-cmp/cmp or a wrapper over that that adds a protobuf comparer might be what I'm looking for. |
…en only gen protos in the target directory when go is the output language
* golang/protobuf#39 not sure how this will get closed out but until then only gen protos in the target directory when go is the output language * fixed arg ordering
How do I add the plugins=grpc to protoc --go_out=paths=source_relative:. foo.proto |
Everything before the
|
Thanks alot, works like a charm |
Some of this is from: https://github.com/jaegertracing/jaeger/blob/master/Makefile#L393-L461 Also got caught by this: golang/protobuf#39 Signed-off-by: William Stewart <[email protected]>
Any updates on this? |
This should be fixed in the v1.20.0 release. |
Passing multiple packages' worth of *.proto files currently fails when using (protoc-gen-go)[https://github.com/golang/protobuf/blob/master/protoc-gen-go/generator/generator.go#L612:L614].
The same functionality is supported by other generators (at least the C++ generator shipped with protoc). protoc-gen-go should support this as well.
The text was updated successfully, but these errors were encountered: