go_library: add experimental importpath_aliases attribute#2068
Merged
jayconrod merged 3 commits intobazel-contrib:masterfrom Jun 28, 2019
Merged
go_library: add experimental importpath_aliases attribute#2068jayconrod merged 3 commits intobazel-contrib:masterfrom
jayconrod merged 3 commits intobazel-contrib:masterfrom
Conversation
importpath_aliases lets a go_library specify a list of secondary names by which it may be imported. This is necessary to support minimal module compatibility. For example, suppose we have module example.com/foo/v2 which doesn't use major version subdirectories. example.com/bar imports a library in this module as example.com/foo (not v2). In GOPATH mode, 'go build' internally translates the import example.com/foo/v2 to example.com/foo. To support this in bazel, we'll require importpath_aliases = ["example.com/foo"] so the library may be imported with either name. Gazelle may generate these attributes, given a command line option. Go 1.14 will likely have more powerful replace directives, which will also let users import packages within a module by multiple names. importpath_aliases will be useful for supporting that as well. Fixes bazel-contrib#2058
Collaborator
Author
|
Holding off on submitting until the corresponding change is in Gazelle so the whole thing can be verified. |
yushan26
pushed a commit
to yushan26/rules_go
that referenced
this pull request
Jun 16, 2025
…azel-contrib#2068) This is just a small PR to reduce the scope of bazel-contrib#2059. This just moves some code from one python file to a separate one. Work towards bazel-contrib#260, bazel-contrib#1105, bazel-contrib#1868.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
importpath_aliases lets a go_library specify a list of secondary names
by which it may be imported.
This is necessary to support minimal module compatibility. For
example, suppose we have module example.com/foo/v2 which doesn't use
major version subdirectories. example.com/bar imports a library in
this module as example.com/foo (not v2). In GOPATH mode, 'go build'
internally translates the import example.com/foo/v2 to
example.com/foo. To support this in bazel, we'll require
importpath_aliases = ["example.com/foo"] so the library may be
imported with either name. Gazelle may generate these attributes,
given a command line option.
Go 1.14 will likely have more powerful replace directives, which will
also let users import packages within a module by multiple names.
importpath_aliases will be useful for supporting that as well.
Fixes #2058