-
-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
Description
go_prefix is used to translate Bazel labels (for example, //foo/bar:go_default_library) to Go import paths (example.com/repo/foo/bar) and vice versa. There are a number of problems with go_prefix, and we'd like to stop using it and eventually stop supporting it.
- Go rules implicitly depend on
//:go_prefix. This means there must be ago_prefixdefined in the repository root package, even if there are no other Go rules in that package. - This does not work well for Go subtrees that are part of larger repositories. The actual import path of libraries within the repository may not correspond to
<go_prefix>/<subtree>/<library>. - This does not work for vendoring. We have special cases for vendoring in several places.
- It's confusing and unexpected that
go_prefixis required forgo_binary. For binary-only repositories, it shouldn't be required at all.
We would like to move away from using go_prefix. go_library already has an importpath attribute, which allows the import path to be set explicitly. This is currently optional, but it may be required in the future.
We will deprecate go_prefix slowly in several steps to avoid breaking people.
- Gazelle will add
importpathattributes to new and existinggo_libraryrules. These import paths will match the import paths that already would be computed, based on the currentgo_prefixand the relative path within the repository. go_prefixwill no longer be mandatory forgo_libraryrules that specifyimportpath. We should be able to accomplish this with computed dependencies.- Gazelle will no longer generate
go_prefixrules. When Gazelle is run with the "fix" command, it will remove existinggo_prefixrules. - At some point in the distant future, we may remove
go_prefixaltogether (this might not actually happen, but it's the plan of record).
Reactions are currently unavailable