-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
x/tools/go/packages: document GOPACKAGESDRIVER #34341
Comments
This sounds related to https://golang.org/cl/184943, which documents this environment variable in the code: https://github.com/golang/tools/blob/3b4f30a44f3bd52b676ee9e88db10d11971b7363/go/packages/external.go#L19-L28 /cc @matloob who may be able to explain why this is not exposed in the public documentation. |
Ping! |
We didn't document GOPACKAGESDRIVER earlier because it wasn't as stable, but I think it's reasonable to add documentation now. |
@matloob, @jmhodges, @toothrot: I noticed gopackagesdriver is now deprecated (as of gopls 0.5.3) Do any of you know if there is an alternate path for resolving packages (E.g. Buck) to provide gopls? |
gopackagesdriver is still supported in go/packages--the reason it was disabled in |
@stamblerre thank you for the clarification! We have a gopackagedriver for gopls so I'm trying to figure out a path forward. The commit above mentions gopls only supporting the go command, does (as I ask this I realize that's what this very PR may be about, sorry for my confusion) |
So the default gopackagesdriver is a |
@stamblerre That would be incredible! What can I do to help? If I modify our gopackages driver to behave more similarly to go list, will that make integration easier? |
That shouldn't be necessary--as long as it produces the correct output it should work. I would guess that we would need to revert https://golang.org/cl/268977 and then confirm whether or not One thing that will be particularly tricky is our package metadata invalidation logic--for example, Bazel relies on BUILD files, but |
I've reverted that change locally and I'm still not seeing gopls using the external driver. I believe we're currently on 0.5.0. That sounds similar to Buck and TARGETS files, our gopackagesdriver daemon watches for file changes to update its cache. It's working currently as the driver can return the updated packages with each gopls request. |
It may be tricky to work with older versions of
The issue is that |
Oh, sorry, I phrased that weirdly.
This is the version of gopls that we are running currently and it works wonderfully with gopackages driver.
This testing (reverting the force of Even if I modify
Got it, is this related to changes since 0.5.0? What I'm seeing in 0.5.0 is that every event for gopls (like hovering, requesting auto-complete, etc) will send a P.S. I really appreciate your time and help with this! |
Hm, this may take a bit more debugging then. I will try to look into it when I get a chance, but that may not happen until after February, as we are currently focusing on stability-related fixes for golang/vscode-go#1037. To debug this, I would except you will want to add some logging throughout the logic that populates the environment and confirm that
This may actually be the result of a bug -- I'd be curious to see a |
GOPACKAGESDRIVER environment variable (although I'll test out with a named binary also, that could simplify things)
Ah, very fortuitous then in this case! This bug(?) is what prompted us to build a daemon mode for our gopackagesdriver, and seems like the only reason it works at all :) I'll keep digging in and see what I can do to get 0.6.0 working with our go packagesdriver and hopefully share some of that here. Thanks again for the pointers! |
I'm planning to work on a gopackagesdriver implementation for bazel soon, and would also like to make sure it works with gopls. For the metadata invalidation, would it help if we included the BUILD or TARGETS files in Package.OtherFiles so you know what to watch? |
That's awesome! I'm sure you've already seen bazel-contrib/rules_go#512, but I believe some work has been done on this in the past.
That might be a start, but the issue is a little bit deeper than that. Right now, we avoid excessive calls to the |
What's the best place to ask questions about implementing the gopackagesdriver? E.g:
|
Ok, fixing other problems resolved my second issue, and gopls seems to be working with bazel names for package ids. |
@stamblerre, @matloob, et al., would you be able to enumerate these assumptions concretely? Motivation: We are interested in using a custom |
@matttproud Here's what I've found with my bazel driver:
It also seems you have to configure the editor to ignore things like bazel-out and bazel-bin/**/.runfiles. |
Change https://go.dev/cl/547977 mentions this issue: |
There is currently no documentation that shows up on godoc.org for the
GOPACKAGESDRIVER
environment variable. However, it's very useful for alternative build systems to provide lookups forgopls
and other tools. For instance, it's mentioned in the bazel rules_go design doc for editor support.It'd be nice for
GOPACKAGESDRIVER
to have publicly available documents.The text was updated successfully, but these errors were encountered: