-
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: Overloading option go_package to indicate Go import path #139
Comments
+1 support this |
One extra thing I forgot to say. This would permit passing |
Ya this would solve a lot of problems I have had on a mental todo list, |
Make sense. |
I am cautiously optimistic :) |
I am +1000 on being able to specify output location using Personally, I would just use periods: since they're currently replaced with underscores, it'll break only people who were using periods and trusting they'd get replaced with underscores, and those people can just use underscores now. In fact, I'd go further, and use |
One other note: while making this change, it might be the right time to ask whether |
This is not universally true, please don't do this. On Wed, Mar 2, 2016 at 9:20 AM, Zellyn Hunter [email protected]
|
@tamird I'm guessing you just never use |
https://github.com/cockroachdb/cockroach/blob/master/build/protobuf.mk#L61 On Wed, Mar 2, 2016 at 9:33 AM, Zellyn Hunter [email protected]
|
@tamird Oh interesting. What do you do about this? https://github.com/golang/protobuf/blob/552c7b9542/protoc-gen-go/generator/generator.go#L1279 And this? |
I think I'm taking this proposal off-topic, though. I don't want to detract from my +1000 on being able to place output files using |
@zellyn lots of |
@tamird o_O Then again, the protoc wrapper I'm writing has a sed-like stage :-( |
@tamird I feel like the fact you use |
I'm not changing how @zellyn: The proto I was anticipating identifying the new form of |
I understand (all too well :-)) how it works now. And neglected to notice previously that using LGTM |
Let me know how it goes. If everything looks fine, I plan to chase up the |
Fantastic! I'll let you know how this turns out as soon as I can: I first have to add go_package to everything, and also get us into vendor folder instead of godep path rewriting... should be soon though :-) |
@dsymonds : Could you give an example of what the canonical protos would look like (any.proto, descriptor.proto, duration.proto, etc.) with this? |
descriptor.proto isn't such a proto. But I hope to change duration.proto to have a line saying option go_package = "github.com/golang/protobuf/ptypes/duration"; |
Well there might be a thing. This would mean I would have to fork the .proto files. Maybe that is ok, since maybe I am going to that anyway. |
@dsymonds What is the package for descriptor.proto? Is there a standard way to do reflection? |
I don't understand your question. |
@dsymonds do we need a separate |
@dsymonds We still don't have I hope those lines can appear in protobuf 3.0.0 or beta-3. |
Wow this needs to be linked on the README. Went hunting for quite a while to figure out the fix for proto subdirectories. Our original solution was to import the entire |
I think it's better to give the usage of 'go_package' option in the README page. |
Right now, a
.proto
file can have a line likewhich means that the generated
.pb.go
file should have apackage foo
statement.I am proposing to overload this option with two new possible syntaxes:
This means that generated code should be dropped into the
github.com/example/foo
directory (relative to whatever is passed to protoc's--go_out
flag), overriding the default behaviour of matching the path to the.proto
file. It also means the.pb.go
file should have apackage foo
statement.This means the same as the previous syntax, but additionally means that the
.pb.go
file should have apackage bar
statement, for the rare cases where people want the package name to differ from the final path component of the import path.This would hopefully mean that far fewer
M
parameters need to be passed through the--go_out
flag. It would subsume #137 and maybe #63.Thoughts? Opinions?
@robpike @zellyn @mwitkow @awalterschulze @peter-edge @tamird
The text was updated successfully, but these errors were encountered: