-
-
Notifications
You must be signed in to change notification settings - Fork 661
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
go_proto_library: default "compiler" misinterprets importpath value with semicolon package name suffix #3235
Comments
cc @codyoss |
Last time I tried something like this, it wasn't supported and I went a different route. I don't think anyone has implemented that but would be very happy to help if you think it's a feature we should adopt. I would like to bear in mind the efforts of WDYT? |
Yeah, I hear you, and we may just do that, but I felt like it was worth a question to y'all :)
To be clear, the feature in question is (properly) supporting the I would understand if the
I'm all for "standard" :) Happy to look into this. Do you have an issue or RFC you could point me at? |
Fast answers are better than slow ones so here is the quick one:
Yeah, there is a lot of infra built on |
Slower answer broken out because I have low confidence in my ability to find random Google Docs links.
Yeah, there is a push to do something common for proto described here. This is the most promising design doc on the topic so far but it seems to be moving at the speed of Google Open Source 😉 (said as a Xoogler who spent many moons fighting the machine). |
I think it's actually very close - it is supposed to land in 5.3.0: bazelbuild/bazel#15854 (comment) I will definitely take a deeper look when it has been released and see whether we can use it to improve |
@fmeum awesome, good to know! So in the meantime, do y'all think we should "patch" the existing behavior to be opinionated about the format of I think this would be a bit of churn, and I'm not sure how offensive the existing behavior is (allowing WDYT? |
Out of curiosity, is there anywhere other than the |
@achew22 I don't think so, as it is kind of a Go-ism. The other proto language options have their own language-specific formats. However, the protobuf-go generator does support a plugin option |
@noahdietz can you point me to another place in the go ecosystem that is using the |
@achew22 I must correct myself, it isn't a Go-ism, but really a protobuf-go idea. |
@noahdietz, given that it is a protobuf-go specific concept, I think adding it into rules_go is probably not the right move. I guess we could work on Gazelle to make it possible to parse the |
I think the important bit here is that there is a way to overwrite the import and package. Exposing a package override as a separate attribute would be fine too, but the |
Maybe I'm confused here, but when I think of the
Are we talking about the same thing? |
We are indeed. In Go it is completely valid to have an import-path of
|
From an admittedly cursory reading of the code, I don't believe If the problem is that |
Ok, so this is specific to So with the protobuf compiler, protoc, and the protobuf-go code generator, the generator will refer to the The same could be said for rules_go, with the exact same proto and an Now, at this point, I'm not necessarily pushing for one thing or another, but I want to clarify what the behavior should be. So... I'm guessing that the Where I got to the point of opening this issue was when I experimented with setting the So I'm not sure if it is an accidentally half-implemented feature (that the generated FWIW, protobuf-go does have a plugin option that allows one to override the Sorry for the wall of text. Much of this detail I should've included in the original bug. |
I'm very happy to have this! Thank you for taking the time to do this. I think we're spun up to the same level. Just to echo this back. I believe your problem statement goes like this:
To fix this you would like to make Assuming this is the case, it's my understanding that the value generated by Gazelle does this properly. We even have test cases to ensure we're extracting it properly. Then when it's turned into the So, I guess my question is a little bit further back in the stack -- why not use Gazelle to generate these? It seems to me that it is already aware of this syntax and has an implementation that handles it properly. |
What version of rules_go are you using?
v0.33.0
What version of gazelle are you using?
v0.24.0
What version of Bazel are you using?
v5.2.0
Does this issue reproduce with the latest releases of all the above?
Yes.
What operating system and processor architecture are you using?
Linux, AMD64
Any other potentially useful information about your toolchain?
Using the default "compiler" for go_proto_library, not using a custom
go_proto_compiler
target for custom generation options. I realize that is another approach to take, but wondered if the below was an issue or not.What did you do?
Supplied a
path;package
format value to theimportpath
attribute of ago_proto_library
target. For example,google.golang.org/genproto/googleapis/cloud/secretmanager/v1;secretmanagerpb
What did you expect to see?
The generated code in bazel output with directory name
google.golang.org/genproto/googleapis/cloud/secretmanager/v1
.What did you see instead?
The generated code in bazel output with directory name
google.golang.org/genproto/googleapis/cloud/secretmanager/v1;secretmanagerpb
.The goal was to see if we could override the importpath and package name with go_proto_library targets. The generated package name is properly updated, but the resulting directory structure of the generated code incorrectly includes the
;package
section of the value.I'm not sure if using
path;package
syntax is actually allowed withimportpath
. If it isn't, perhaps lets throw an error? If it is, perhaps we should fix the generated directory structure to trim the;package
suffix.The text was updated successfully, but these errors were encountered: