-
-
Notifications
You must be signed in to change notification settings - Fork 662
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
Expose generated Go files to editors and IDEs #512
Comments
This issue is in response to Bazel build, protobuf and code completion. TODO: update answer when this issue is resolved. |
What the status of the task? |
So, I have proposal how to close this issue. Suppose you generated code: Let's add symlink Use in your files As result you will get workable code-completition AND workable build. |
@excavador We're still developing a more complete solution to this (the workspace abstraction I mentioned above). Ideally, tools won't need to be aware of the project layout in use. I don't have any ETA for that yet, but we are making progress. As you showed, it's possible to work around this with symlinks. You can also copy or symlink generated files into your source directory. Bazel will prefer a generated file if a source file of the same name is present. I'd recommend against checking generated files into VCS though. |
Thank you for notify! Will wait. You can consider me as closed beta-tester :) |
Any updates? |
@raliste it works for me in IDEA Ultimate + Bazel plugin with following limitation: autocomplete works only if all files inside golang package are auto-generated. If mix together auto-generated and manually written file, autogenerated file would not be inspected |
The workspace abstraction mentioned above is being actively worked on. We've gone through a lot of internal prototypes, and we're in the process of reviewing, testing, and merging one that we're pretty happy with. It's a huge body of code though, and it will take time. Following that, a large number of Go tools will need to be updated to use the workspace abstraction so they can function in "go build", vgo, Bazel, and other kinds of workspaces. I know it seems like progress is slow, but it's an interface that many, many tools will interact with, and we want to be sure we get it right. It's a huge amount of work, but it is our highest priority task. |
@jayconrod Are there any public discussions about that? Design docs perhaps? |
Not yet, but soon. We're still working on simplifying and narrowing the interface. |
Can you briefly explain how this workspaces feature is going to work? |
The first public piece of this is |
@jayconrod Any updates on the proposed workspace abstraction layer? |
@akshayjshah We've made some progress. The If you set the So ideally, once that change is in, you'd be able to build and install the driver into your |
Thanks for the update! Would you be willing to push your driver to a branch so I can take a look? I'm not in a huge rush for you to officially release it, but I'd love to use your rough draft to better understand how these pieces should fit together. |
@akshayjshah Sure, it's at https://github.com/jayconrod/rules_go/tree/dev-gopackagesdriver if you'd like to take a look. As I said, it's very rough right now. |
That looks awesome, thanks! Is there any update on this? |
@pierreis Sorry, no updates since my last comment. I'm still planning to work on this this quarter. There are a lot of things going on, but this is one of the higher priority projects. |
Generated .pb.go files are now available in the Leaving this issue open though since it's not documented yet. |
@jayconrod is package driver still planned as a feature or are we going to rely on the aspect-based approach mentioned above? |
A driver is still planned, but I don't have any update to share yet. Implementation-wise, the data will be produced by the builder and accessed through an output group (but the driver will hide those details). |
@jayconrod, has there been any progress on the workspace abstraction? |
We can use rules_go to create a fake symlink farm GOPATH. This can be set as the GOPATH in IDEs that do not have native support for Bazel, and we can stop maintaining the bazel_copy_generated_for_ide.sh hack. The remaining issue is that we still need Go tooling to manage our go.mod file that serves as the input to Gazelle, so we need to add replace directives to ensure that Go tools can resolve generated code. The proper fix for all this is the upcoming native Bazel support in Go: bazel-contrib/rules_go#512 Test Plan: Ran `bazel build :gopath`, and a wild `bazel-bin/gopath/src/git.monogon.dev/source/nexantic.git/core/generated/api/schema.pb.go` appeared. `scripts/symlink_generated_files.sh` created a valid symlink in core/generated and `go mod tidy` ran successfully (despite complaining about the symlink). Running `scripts/gazelle.sh` twice worked. X-Origin-Diff: phab/D305 GitOrigin-RevId: 0d456bc57d4a2d72e30865ffef777d2f5be5c407
I have a useable |
What is left to do here? |
Is there an explanation of I've set the environment variable to the location of |
The explanation is at https://github.com/bazelbuild/rules_go/wiki/Editor-and-tool-integration |
What's the status of this issue? Wondering if that's the state where IDE support is currently at right now, or if I'm missing something. |
I forked the rules_go version and made a few changes. Most notably, I split
the package driver into a server and client that communicate using gRPC.
The idea was to allow the driver to persist things in memory between runs.
It should also be easier to debug because attaching to the server is easier
than attaching to the binary launched by the go-pls. The client launches
the server automatically, and the server dies after an idle period.
The code is still pretty messy. I spent a decent amount of time getting
integration testing working beyond the support available from rules_go
today. A test workspace gets brought up inside a sandbox with no network
connection, which isn't supported by current bazel go integration tests.
It is not really in a user friendly state now. But if Uber is about to
invest in improved tooling, it might be worth a look.
https://github.com/gonzojive/bazelgopackagesdriver is the repo. I may still
have local changes that need pushing.
…On Mon, May 9, 2022, 7:47 AM Zhongpeng Lin ***@***.***> wrote:
Uber is planning to invest into GOPACKAGESDRIVER in the coming months.
You should see PRs from me, @JamyDev <https://github.com/JamyDev> @blico
<https://github.com/blico> fixing the major issues and potentially
improve the performance.
—
Reply to this email directly, view it on GitHub
<#512 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAUO557WCAC2R52RTZL6HTVJEQQJANCNFSM4DOFWFCQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
There's no mention of JetBrains GoLand editor on this thread or on the wiki https://github.com/bazelbuild/rules_go/wiki/Editor-and-tool-integration Assuming that this ticket still represents the current state: It seems like that's a mistake? |
We made IntelliJ Bazel plugin work for Go internally in Uber, but PRs to upstream our changes have been stalled for months (bazelbuild/intellij#2973). |
I'm having some trouble with the language server's compiler IDE suggestions since switching to using the GOPACKAGESDRIVER. Any suggestions would be greatly appreciated. I have a project that's structured as follows:
Before making the change, I had However, this is clearly not a real issue as the code compiles and works successfully. Any ideas why this change might have introduced this strange error? |
Painful but works: bazelbuild/intellij#194 (comment) (need to cp your *.pb files manually) |
@loeffel-io shouldn't need to be manual, see https://github.com/aspect-build/bazel-examples/tree/main/write_source_files |
Kythe.io, Google's code-intel indexer, indexes most Google's languages into a universal syntax tree using Bazel's aspect (exp action listener, but that is being deprecated in favor of aspect). This universal syntax tree is then stored into LevelDB(in the open source version) and served via HTTP for codesearch frontend. What does this mean?
This would be a super interesting area to dig into for those who are interested 🤗 |
@linzhp is there an easy way to use your plugin version locally? |
@JamyDev Do you think it's possible to open source part of our fork to your personal GitHub account, as a staging area for upstreaming them in the future, and for other people to try out before Google accepts our PRs? |
@linzhp For now i could build your plugin myself and publish the zip file - but it looks like your branch is pretty outdated |
Hi @linzhp, thanks for improving this amazing tool. Any plan to issue a PR on https://github.com/linzhp/rules_go/? Looking forward to use this tool inside my repository! |
If we are going to send a PR, it will most likely go to https://github.com/bazelbuild/intellij |
Improved workaround for now for a proto external repository (no intellij Go Modules toggle required):
|
Closing this as done. Actually it's been done for a couple years I think. The wiki page Editor setup has instructions on how you can get this to work on editors that use gopls. Editor and tool integration explains how it works. And, shameless plug, I gave a talk about it. Thanks to everyone who worked on this, special shout-out to @steeve @linzhp and @fmeum. If you find bugs or have feature requests (including those unaddressed in comments above), please open new issues, narrowly scoped so they're easier to track. |
When a library is created with
go_proto_library
or some other mechanism that generates Go code (.pb.go files in this case), the generated sources files are not exposed to editors and IDEs. Consequently, code completion and refactoring tools don't work, lowering developer productivity.The Go team is developing a workspace abstraction mechanism that will allow editors and Bazel (and other build systems) to communicate with each other without the need for direct integration. This is the long-term solution to this problem.
This issue will track progress on the workspace abstraction and will track editor awareness of code generated with Bazel.
The text was updated successfully, but these errors were encountered: