-
-
Notifications
You must be signed in to change notification settings - Fork 664
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
Use package name instead of go_default_library to define a default library #265
Comments
TL;DR: will make bazel semantics act strangely. rules_go supports both the OSS Go way: package/binary 1-to-1 with directory 'go_default_library' (and companions) means "do it the OSS way", while anything else means do it the bazel-way. |
The kythe project already accomplishes my suggestion through the use of a Skylark macro (maybe we can make this macro a standard part of rules_go?): At least one person has requested an even more generalizable approach (have an optional import_name parameter for go_library) that would allow us to accomplish the same thing and more: |
I'm the person requesting the importpath parameter. I think DrMarcII's request is somewhat orthogonal to my request. In particular, I don't want to attain DrMarcII's desired behavior by adding an importpath specification to every one of my BUILD rules. I'd rather behavior described in this Issue be the default, but still have importpath as an override. All of the Bazel+Go code I've seen relies on the Go OSS way already, since most Go code is written and organized without Bazel in mind. Using the package name instead of the "go_default_library" way would result in cleaner BUILD files in this common case, and the importpath parameter would provide flexibility to those who want to use the Bazel way. The downside of this approach is that it breaks existing behavior. |
The go rules are now capable of operating this way, and do also support an importpath parameter, but gazelle still generates build files with go_default_library type names. |
(Closing old Gazelle issues. This one is migrated to bazel-contrib/bazel-gazelle#5). |
Currently if you have lib/BUILD with
That is used in test/test.go, you would import as:
But would have to have the following in test/BUILD file:
It would be cleaner if instead, you could set the name to "lib" in lib/BUILD and have the deps be "//lib" in test/BUILD while keeping the import in test/test.go the same.
The text was updated successfully, but these errors were encountered: