Skip to content
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

Update go_repository defaults to only use Go code #1888

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Oct 4, 2024

  1. Update go_repository defaults to only use Go code

    This is an attempt at making `go_repository` and its bzlmod equivalent
    pull Go modules as similar as possible to what `go get` would do: no
    proto generation, and no BUILD files.
    
    In my experience, the bulk of Go modules that ship with BUILD files
    don't actually compile, so we need Gazelle to fix them for us. In
    general Gazelle does a great job at these, but sometimes they will
    contain `genrule`s and other code meant for updating the sources, and
    in some cases Gazelle just can't fix those.
    
    I previously added `build_file_generation=clean` for this, and it works
    great under `gazelle_default_attributes` in my local tests. So, this
    commit makes that the default. Gazelle's build file _updating_ is great
    for local development, but it almost never makes sense for an external
    Go module pulled in via go_repository/go_deps.
    
    The same thing applies to protobuf. Some module authors ship .proto
    files in their codebase, which is great! However, since Gazelle doesn't
    really implement dependency resolution for proto files (which is fair,
    because that's _hard_), we end up with a lot of `gazelle:proto disable`
    everywhere, because we import modules without using the proto files.
    
    So, we can insert `gazelle:proto disable` by default for external
    repositories. When the proto targets are actually needed, they can be
    reinstated by passing either an empty directives list, or (more likely)
    by providing the dependency resolution rules.
    
    The end result is that go_repository and go_deps now basically don't
    need special configuration or overrides anymore, as evidenced by my
    cleanup in `default_gazelle_overrides.bzl`.
    TvdW committed Oct 4, 2024
    Configuration menu
    Copy the full SHA
    62181b1 View commit details
    Browse the repository at this point in the history