-
Notifications
You must be signed in to change notification settings - Fork 10
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
Support for other build systems through GOPACKAGESDRIVER #3
Comments
Thanks for making a new issue here :) Do you know of any open source projects using please to build a go project? I'd love to take a peak at those and explore. If not, I'll do some looking around this week and see what I can dig up. |
Hey! There are a few around: We haven't gotten the go list driver out the door though, so you might have better luck with Bazel: |
Ah, so there exists a go list driver for Please? (just not currently available to be run outside of your environments?) I'll check out the stuff for bazel as well. Thanks |
Yeah, there's a prototype but it's not fit for purpose. I was trying to understand how this stuff works, and got the implementation fundamentally wrong. I think I know what to do now but haven't gotten around to it. |
cool, i'll look into using an alternate driver and what we would need to do. In this iteration, we are using the |
Ah, I think I see the problem more clearly now -- sorry, I must have misunderstood at the beginning. The primary thing I need to remove are any calls to Looking into that now :) |
Hey @tjdevries, I played around with |
I think one of the easier ways to test with a Go packages driver is to run against rules_go. It has a packagesdriver in
(Not defining the query_scope one will make it just spit out the stdlib, which could be useful too) |
This might be a me problem, but I don't have a module name to provide. If you absolutely need to know the root import path for the codebase, we can probably just do a big refactor. |
No this is a fair usecase, if you don't have a module name then we need to get it from somewhere! |
@Tatskaari Are you saying you don't have a module name for the project as a whole, but it's composed of smaller modules (where some depend on each other)? In that case, I think we should be able to just override the modulename with (sorry, I was traveling last week so I haven't had a chance to investigate this aspect of the project much more yet) |
Maybe an example will help. So we have a repo that vaguely has the following structure:
In
These imports are resolved relative to the root of the repo. Perhaps we can pass in "." as the module name? I'm not sure how that will work as the import paths don't start with "." or anything. We do actually want to refactor this to include a root import path so it might become |
Hey, sorry for the long delay -- I think I'm at least pretty close to making it possible to skip all of the direct shelling to If you do something like:
And possibly use the GOPACKAGESDRIVER to provide ways to load the dependencies, does that work for you? (again, sorry for the delay. Got side tracked on a few other projects. I'm hoping to grab some time to fixup any problems here) |
No worries, things are pretty chaotic here too but will try and give this a go soon. Thanks for the hard work 🙂 |
If you can try on any open source repos that are representative of some of the stuff that you all are doing, that'd be super awesome -- that way I can try it more on my end and iterate towards a solution without having to bother you a ton. We're experimenting with bazel for building sourcegraph, so I might be able to try and run it locally against sourcegraph's repos, which would be a good test case for this. |
I have a test case repo if that's still helpful: https://github.com/aalyria/api This builds with bazel 6.2 and uses the GOPACKAGESDRIVER trick to support the gopls LSP. Here's an example query without $ gopls references ./cdpi_agent/agent.go:53:6
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:105:30-35
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:117:30-35
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:128:30-35
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:170:10-15
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:189:10-15
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:35:36-41
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:38:25-30
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:40:33-38
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:66:38-43
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:67:8-13
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:80:10-15
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:93:30-35 Here's with the GOPACKAGESDRIVER var set: $ GOPACKAGESDRIVER=$PWD/tools/gopackagesdriver.sh gopls references ./cdpi_agent/agent.go:53:6
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:105:30-35
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:117:30-35
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:128:30-35
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:170:10-15
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:189:10-15
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:35:36-41
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:38:25-30
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:40:33-38
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:66:38-43
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:67:8-13
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:80:10-15
/home/ciaran/github.com/aalyria/api/cdpi_agent/agent.go:93:30-35
/home/ciaran/github.com/aalyria/api/cdpi_agent/node_controller.go:47:10-15 As expected, $ GOPACKAGESDRIVER=$PWD/tools/gopackagesdriver.sh scip-go --module-name=aalyria.com/spacetime
scip-go
Resolving module name
Go standard library version: go1.20
Resolved module name : aalyria.com/spacetime
Configuration:
Skip Implementations: false
Skip Test : false
Loading Packages
Visiting Packages
Indexing Implementations
Visiting Project Files:
$ scip stats index.scip
{
"documents": 0,
"linesOfCode": 0,
"occurrences": 0,
"definitions": 0
} |
Updating go.mod:
I tried fixing it. Including It might be that bazel package driver doesn't provide this information, I'm not sure. |
Hey folks,
Would you mind if I make a change to enable supplying target patterns via cli args as other tools support, e.q.
These patterns are described in The good news is when I hack these things locally UPD: Published the PR for specifying packages for indexing #139 |
@varungandhi-src @Strum355 @keynmol @kritzcreek Could you folks take a look on it please? |
@podtserkovskiy can we close this issue now? |
That's a good question, probably yes. I was on the vacation and have not integrated the indexer into our system yet. However it looks like we have no more obstacles for it. |
Hey! We use Please, which means that we don't have a
go.mod
in the root of our repo. Unfortunately this tool assumes that it can usego list
and othergo build
specific commands during initialisation. Other users might be using Bazel or similar, and will encounter similar problems, where these commands won't necessarily work as expected or at all.Fortunately,
golang.org/x/tools/go/packages
supports plugging in a different "go list driver" (example), so in theory, the indexer should be able to glean all the information it needs. This tool likely would need to be re-worked so that it doesn't require as much information up front about the "module" and it's dependencies, as it may not be indexing a module.In our case, we don't even have a base import path. We work in a giant monorepo where the "go path" root is the repo root. We can still service import path wildcards producing all the information that
go list --json
would (i.e. resolving import paths to other packages), just the module field will be empty.The text was updated successfully, but these errors were encountered: