-
Notifications
You must be signed in to change notification settings - Fork 305
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
IntellIJ doesn't recognize generated grpc/protobuf for golang #194
Comments
actually another workaround is setting a $GOPATH and creating the "generated" files into the protobuf. |
Just wondering if there has been any progress on this. I am also encountering this issue, on Bazel 0.16.1 + IntelliJ 2018.1.6 + plugin 2018.08.20.0.3. I have created a repository at https://github.com/hexaglow/bazel-intellij-194 that demonstrates the issue. After importing the project, the generated code cannot be resolved by IntelliJ causing incorrect error highlighting |
Sorry, lost track of this. Does Go protobuf support is already implemented, but the go rules in blaze is sufficiently different from bazel's rules_go that there's a bunch of these issues causing our aspect to not be able to locate go sources with bazel. I think this should be caused by something similar to #360, where go_grpc_library does not contain the provider that we need. |
Using only |
It seems |
Okay, same problem as #214. We'll need |
I have little experience with both Go and this plugin, but managed to get generated ...
elif ctx.rule.kind == 'go_proto_library':
proto_files = getattr(target[GoSource], "srcs", [])
proto_sources = [f for f in proto_files if f.basename.endswith(".pb.go")]
if not proto_sources:
return False
sources += proto_sources
generated += proto_sources
... |
Yes that does work. But then our aspect would not be able to support any project that does not use go. |
In lieu of conditional loads we have at least two solutions that could work today:
Additionally, to pick up everything (eg @chaoren what do you think about option 1 vs 2? |
We talked to the rules_go team about option 1. No chance of that happening. Option 2 makes some sense. Since the .pb.go file is indeed generated, and you can conceivably call that an output. But I think the rules_go team is still expecting this issue to be solved via the current providers. |
I'm not sure if changes are partially done, but it seems that the
However the intellij plugin doesn't seem to take it into account. Using rules_go 0.17.1 |
So I tried out |
For reference in blaze (internal bazel), the import paths are derived from the full target name, and there's no explicit importpath field, so it's literally impossible for this kind of conflict to happen there. |
While creating an example project (https://github.com/vanti-public/ijwb_194) I stumbled across the cause of the issue: Vgo support. Turning vgo support off in the IDE allows the generated proto files to resolve as expected. Turning it on causes the issues I've been having. |
Has anyone found any fix for this? The issue persist only in some packages. Even if it builds and runs correctly some packages won't recognize the generated proto file (even if it is to be found in As #194 (comment) points out changing the importpath seems to fixing the issue. And as I've understood it only happens when there is other sources in the same package with generated sources and both targets have the same importpath |
Good news! I don't know how correct this is but this patch https://gist.github.com/mstg/051d0bf16941df49312b3a80f868903b seems to have worked! Apply it with I can create a PR if this is a desired fix. Please advise. |
I've tried a lot, but GoLand still doesn't recognize generated pb.go file, although Bazel can run target successfully. I think using symlink or writing bzl maybe not the perfect solution, because this should be the plugin's work, and project should only contain business logic. |
I am having the same issue as described by @mattnathan in #194 (comment) - as soon as Go Modules (vgo) support is being enabled in Disabling Go Modules support in IntelliJ works, however this is not really a fortunate solution. The patch provided by @mstg in #194 (comment) unfortunately did not resolve this issue either. |
Hi! This seems to still be an issue unfortunately. As folks mentioned earlier this seems to stem from a conflict with GoLand's Go Modules support, and turning support for it does in fact get rid of the issue. However, that creates another issue. Because Go Modules support is turned off GoLand doesn't pick up any new modules if you update the I'm not familiar enough with how the plugin system works to fix it, but if someone can coach me through it I'm happy to work on a fix! Update: I added a comment in https://youtrack.jetbrains.com/issue/GO-9040#focus=Comments-27-4879464.0-0 because I'm assuming it's IntelliJ's Go Modules integration that is breaking this. I have also created an up-to-date repro at https://github.com/iamricard/goland-bazel-mods-repro. Also, none of the fixes/patches above fix this issue. I think this is because the |
Disabling Go modules also makes sense because Bazel doesn't use it anyway. I'm settling with that. |
Thanks ❤️ |
After upgrading to IntelliJ 2023.1.3, IntelliJ insists on opening my project with Bazel, creating the The good news is that almost everything works, including debugging! The bad news is:
|
Protobuf should be supported for go as of #6030 . |
Sorry for what is a very similar issue to the ones for Java & Python. Not sure if I'm doing something wrong, but IntelliJ won't recognize protobuf-generated types in my go projeccts.
I have an example project that is open source: https://github.com/kopeio/etcd-manager/blob/master/pkg/apis/etcd/BUILD.bazel
For reference:
Not sure if I'm not setting up my project correctly in IntelliJ (GOPATHs? Marking as generated sources?) The workaround I've found is to symlink to
./bazel-bin/pkg/apis/etcd/etcd_go_proto~/kope.io/etcd-manager/pkg/apis/etcd/etcdapi.pb.go
.Any better suggestions appreciated! Or if this should "just work" let me know if I can provide more diagnostic information.
Go plugin version: 173.3727.144
Bazel plugin version: 2017.11.20.0.4
Bazel version: 0.8.1
IntelliJ version: IU-173.4127.27 (aka 2017.3.2)
The text was updated successfully, but these errors were encountered: