bazel-contrib / rules_go

Go rules for Bazel
Apache License 2.0
1.38k stars 656 forks source link

Making gopackagesdriver correctly handle relative queries made from a subdirectory. #4002

Closed waltercacau closed 1 month ago

waltercacau commented 2 months ago

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

It allows gopackagesdriver to be called within a subdirectory of a workspace and properly resolve queries from gopls from IDEs like VSCode when they include relative references. For example, if you have the following repo/workspace structure:

WORKSPACE
project1/BUILD.bazel
project1/main.go
project2/BUILD.bazel
project2/main.go
...

If you run gopackagesdriver using bazel run from project1 directory and receive the following queries:

file=./main.go
./...

The existing code will try to resolve those queries against the root of the workspace, when instead we would expect it to resolve relative to the project1 directory.

Which issues(s) does this PR fix?

Fixes #4001

Other notes for review

JamyDev commented 2 months ago

LGTM!

JamyDev commented 2 months ago

I'll validate it with Uber code on Monday, but I don't expect it to be breaking.

waltercacau commented 2 months ago

Hi there, just checking in, is this PR good to merge?

fmeum commented 1 month ago

@JamyDev I'll merge this now as it looks safe, but please let me know if you discover any issues with it.