bazel-gazelle icon indicating copy to clipboard operation
bazel-gazelle copied to clipboard

Using the repo name rules_go removes proto embed from all go_library rules

Open jschaf opened this issue 1 year ago • 8 comments

What version of gazelle are you using?

0.37.0

What version of rules_go are you using?

0.48.0

What version of Bazel are you using?

7.2.0rc3

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

macOS arm64

What did you do?

  1. I manually replaced all instances of io_bazel_rules_go to rules_go in my repo.

  2. I removed the repo_name from the rules_go bazel dep in MODULE.bazel.

# Before
bazel_dep(name = "rules_go", version = "0.48.0", repo_name = "io_bazel_rules_go")

# After
bazel_dep(name = "rules_go", version = "0.48.0")

What did you expect to see?

Running gazelle should do nothing.

What did you see instead?

Gazelle removed the go_library.embed for every go_proto_library embedded into a go_library.

Before

go_library(
    name = "api",
    srcs = [], 
    embed = [":api_go_proto"],
    importpath = "github.com/arryved/simc/erp/api",
    visibility = ["//visibility:public"],
)

After

go_library(
    name = "api",
    srcs = [], 
    importpath = "github.com/arryved/simc/erp/api",
    visibility = ["//visibility:public"],
)

Debugging

The problem might be that `io_bazel_rules_go is hardcoded: https://github.com/bazelbuild/bazel-gazelle/blob/7d10bf7befce477f518056cfc502939000bea3fa/config/constants.go#L22

jschaf avatar Jun 06 '24 00:06 jschaf