Skip to content

Commit

Permalink
Add support for go_binary to gopackagesdriver.
Browse files Browse the repository at this point in the history
As discussed in bazelbuild#3270, The current implementation of `bazel_json_builder`
does not handle `go_binary` build rules. This means that when
`gopackagesdriver` attempts to be used on a file that is apart of a
`go_binary`, no build target is produced as the output of `bazel query`.
This prevents downstream utilities (`gopls`) from being able to provide
functionality such as autocompletion support.

This PR simply adds `go_binary` as a supported rule type, fixing bazelbuild#3270.
  • Loading branch information
DrewMonroe committed Aug 17, 2022
1 parent bc60909 commit 4f9835d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion go/tools/gopackagesdriver/bazel_json_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (b *BazelJSONBuilder) fileQuery(filename string) string {
fp, _ := filepath.Rel(b.bazel.WorkspaceRoot(), filename)
filename = fp
}
return fmt.Sprintf(`kind("go_library|go_test", same_pkg_direct_rdeps("%s"))`, filename)
return fmt.Sprintf(`kind("go_library|go_test|go_binary", same_pkg_direct_rdeps("%s"))`, filename)
}

func (b *BazelJSONBuilder) packageQuery(importPath string) string {
Expand Down

0 comments on commit 4f9835d

Please sign in to comment.