Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Deprecate and remove go_prefix #721

Copy link
Copy link
Closed
@jayconrod

Description

@jayconrod
Issue body actions

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 a go_prefix defined 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_prefix is required for go_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 importpath attributes to new and existing go_library rules. These import paths will match the import paths that already would be computed, based on the current go_prefix and the relative path within the repository.
  • go_prefix will no longer be mandatory for go_library rules that specify importpath. We should be able to accomplish this with computed dependencies.
  • Gazelle will no longer generate go_prefix rules. When Gazelle is run with the "fix" command, it will remove existing go_prefix rules.
  • At some point in the distant future, we may remove go_prefix altogether (this might not actually happen, but it's the plan of record).
breakds, inas9, emcfarlane and ashi009

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.