-
-
Notifications
You must be signed in to change notification settings - Fork 668
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
Deprecate and remove go_prefix #721
Comments
go_prefix is used to generate Go import paths from Bazel labels. Until now, it has been mandatory, since there's an implicit dependency from all go_library, go_binary, and go_test rules on //:go_prefix. With this change, that dependency is not present when the importpath attribute is specified. This means that if all of the Go rules in a repository specify importpath, there's no need to define a go_prefix rule in the repository root. Fixes bazel-contrib#720 Related bazel-contrib#721
go_prefix is used to generate Go import paths from Bazel labels. Until now, it has been mandatory, since there's an implicit dependency from all go_library, go_binary, and go_test rules on //:go_prefix. With this change, that dependency is not present when the importpath attribute is specified. This means that if all of the Go rules in a repository specify importpath, there's no need to define a go_prefix rule in the repository root. Fixes #720 Related #721
* go_prefix is no longer generated. In a future change, existing go_prefix rules will be removed in fix mode. * All go_library, go_test, and go_binary rules are generated with an importpath attribute. * importpath is now a mergeable attribute; Gazelle will replace existing importpath attributes unless they have a keep comment. This helps keep libraries up to date after they are moved to a new location. Related bazel-contrib#721
* go_prefix is no longer generated. In a future change, existing go_prefix rules will be removed in fix mode. * All go_library, go_test, and go_binary rules are generated with an importpath attribute. * importpath is now a mergeable attribute; Gazelle will replace existing importpath attributes unless they have a keep comment. This helps keep libraries up to date after they are moved to a new location. Related #721
Not sure if it's related, but do we need importpath on Does this Issue about go_prefix also imply that the importpath requirement will also eventually be removed? That would be nice. |
At the moment, Internally, a The one place it is used publicly is the experimental |
|
If Can we use a convention for the path of |
gazelle writes the importpath into the rule for you, so it will always be set anyway. |
Infer test import path correctly from deps Remove importpath from all go_binary and go_test rules Add importpath to all go_library rules Delete go_prefix occurences Progress on bazel-contrib#721
* Fixup importpath Infer test import path correctly from deps Remove importpath from all go_binary and go_test rules Add importpath to all go_library rules Delete go_prefix occurences Progress on #721 * Review fixes
Closing old issues.
|
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 withgo_prefix
, and we'd like to stop using it and eventually stop supporting it.//:go_prefix
. This means there must be ago_prefix
defined in the repository root package, even if there are no other Go rules in that package.<go_prefix>/<subtree>/<library>
.go_prefix
is 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 animportpath
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.importpath
attributes to new and existinggo_library
rules. These import paths will match the import paths that already would be computed, based on the currentgo_prefix
and the relative path within the repository.go_prefix
will no longer be mandatory forgo_library
rules that specifyimportpath
. We should be able to accomplish this with computed dependencies.go_prefix
rules. When Gazelle is run with the "fix" command, it will remove existinggo_prefix
rules.go_prefix
altogether (this might not actually happen, but it's the plan of record).The text was updated successfully, but these errors were encountered: