-
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
How about flags support what option go_package
does
#382
Comments
I think following invocation should do the same (assuming that foo.proto is in current directory) ... protoc --go_out=Mfoo.proto=github.com/rmrf/mypackage/pb/foo:. foo.proto I think specifying inside the proto seems cleaner though and keeps the protoc invocation simpler. |
@cybrcodr your invocation is better, Thanks About why not specify it inside proto, what I'm thinking is: unlike JAVA's Golang's package name have that feature which java don't have. If I want to generate the golang code for this .proto file, what I'm really need is put this generated golang code into my project, which not only have package name, but also means how to reach it. espestially when I'm working with other team's proto file repo: I can't change theirs .proto file, but I need generate golang src code base on them - and integrate into my project (with my package namespace and url reach way) That's why this confuse me, I can't figure out better solution yet. |
A proto message type should be unique within a binary, unless you're assuming the use of type aliasing or unless it is hidden (internal or vendored), the Go import path of a message type does matter. If you are using another library that uses the same proto message type as your library/binary does and you pass/receive it as argument from that dependent library, then that message type should be the same. That's the reason why I suggested having it in the source proto file for specifying the package path+name, but can certainly be done via invocation as well, in which case, need to make sure that both parties are using the same invocation or same generated code. Hope that helps. |
I'm closing this issue, but feel free to ask more questions. |
I have go through #39, so I'm thinking is that a better way to let protoc support this kind of flag ?
and this have same effort with: add bellow into
foo.proto
fileor does protoc already have simillary way: which do not need modify .proto file, but generate specific import path package.
The text was updated successfully, but these errors were encountered: