-
Notifications
You must be signed in to change notification settings - Fork 14
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
Don't panic on missing pkg.Module when GOPACKAGESDRIVER set #138
Don't panic on missing pkg.Module when GOPACKAGESDRIVER set #138
Conversation
I'm not opposed to merging this PR, but I'd like to better understand how we're supposed to test and maintain this, even if that requires manual steps. |
Thanks for reviewing this PR
I think this is implemented only for go.mod because "module" is
Then it can be used with Go tools like this
It won't work and this is okay the goal of issue #3 is to enable |
b09bfc6
to
b45635d
Compare
Understood. Could you please do the following:
If you don't have time to implement the above, let me know, and I'll work on adding these. Other question: we have this section in the README.
Do we need to update the code shelling out to the |
I think UPD: Actually I feel like "Indexing without shelling to go binary" section can be removed if we disable the shelling when |
b45635d
to
470d58f
Compare
I did few changes:
I haven't touched the code related to shelling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the comments so far.
The config.IndexOpts doesn't exist when main.go calls modules.ModuleName so it can't access IsGoPackagesDriverSet. We probably can call modules.ModuleName from config.New to avoid this problem.
There is also a code path initializing defaultGoVersion
which needs a Go stdlib version for cross-repo navigation. Given that supporting cross-repo navigation with a custom driver is not a goal here, it's fine to use a placeholder value here with an explicit TODO.
@@ -164,6 +164,23 @@ func normalizePackage(opts *config.IndexOpts, pkg *packages.Package) *packages.P | |||
// Path string = "github.com/efritz/pentimento" | |||
// Version string = "v0.0.0-20190429011147-ade47d831101" | |||
|
|||
if opts.IsGoPackagesDriverSet { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if opts.IsGoPackagesDriverSet { | |
// As of golang.org/x/tools v0.26, the JSON object for representing packages | |
// does not have a Module field: | |
// https://github.com/golang/tools/blob/v0.26.0/go/packages/packages.go#L609-L627 | |
// which means that cross-repo navigation may not work out-of-the-box | |
// for 3rd party build systems like Bazel, Buck2, Please etc. using GOPACKAGESDRIVER | |
if opts.IsGoPackagesDriverSet { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I applied the code suggestion.
There is also a code path initializing defaultGoVersion which needs a Go stdlib version for cross-repo navigation. Given that supporting cross-repo navigation with a custom driver is not a goal here, it's fine to use a placeholder value here with an explicit TODO.
I guess we can use defaultGoVersion for now, if someone needs to have a specific value here, they can use --go-version
flag
470d58f
to
65bb6cb
Compare
65bb6cb
to
38afd92
Compare
Thank you for the review&merge 😀 |
FWIW around adding the module field, we asked about this a year ago: golang/go#62601 |
@JamyDev Thanks for the heads up, but I'm not sure what what is the closest analogue of "Module" we can have in Buck. The module seems to be the We definitely can emit module information for third-party packages, but I don't have a clear picture of a first-party module implementation in Buck. |
GOPACKAGESDRIVER
's JSON doesn't provideModule
field.I've changed panic to an error message to enable usage of
scip-go
with third-party build-systems like Buck2 or Bazel.Related: #3