Skip to content

Implement go/packages API #1644

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

Open
jayconrod opened this issue Aug 9, 2018 · 0 comments
Open

Implement go/packages API #1644

jayconrod opened this issue Aug 9, 2018 · 0 comments
Labels
enhancement go tools Support for editors, analysis, and refactoring tools

Comments

@jayconrod
Copy link
Contributor

We need a tool that can provide data from Bazel workspaces to golang.org/x/tools/go/packages.

This will provide information about Go code in Bazel workspaces to clients of the go/packages API.

@jayconrod jayconrod added enhancement go tools Support for editors, analysis, and refactoring tools labels Aug 9, 2018
abhinav pushed a commit to uber-go/cff that referenced this issue Oct 19, 2022
This commit allows CFF to get package information for dependencies from
archives instead of virtualizing a gopath in the Bazel sandbox. A later
diff in the stack enables this feature in the CFF Bazel rules, so this
commit itself should not yield any performance gains.

Currently, Bazel (v0.29.1) does not have a `go/packages` driver
(bazel-contrib/rules_go#1996,
bazel-contrib/rules_go#1644), and to use the
`go/packages` package, it requires virtualizing a gopath, which is
expensive. This stack of commits can be reverted if the gopackages
driver is later implemented in Bazel.

See D3490189 for a similar change for Glue. The key difference in the
two diffs is that for Glue, it parses the archive file for the library
itself, whereas for CFF, it parses the archive files for the library's
dependencies and reads the CFF source files directly. The key reason for
this is because of the "cff" build tag; since Bazel does not provide a
way to pass in build tags to the go_library rule, the archive file
generated for it excludes files with build tags. Consequently, parsing
the archive file for the library itself yields a package without any of
the actual CFF source code.

The build tag is irrelevant for the Bazel system, so just removing the
CFF build tag for all CFF files could have been an option. Instead, we
opted to parse the dependencies' archive files to build an importer,
since we wanted to keep the possibility of using CFF as a binary outside
of the Bazel system.

Refs T4309403
Reviewed-on: D3533489
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement go tools Support for editors, analysis, and refactoring tools
Projects
None yet
Development

No branches or pull requests

1 participant