Skip to content

FR: Gazelle should import direct dependencies directly without requiring buildozer #1749

Closed
bazel-contrib/rules_go
#3927
@vicentsegui

Description

What version of gazelle are you using?

0.35.0

What version of rules_go are you using?

0.46.0

What version of Bazel are you using?

7.0.2

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

Yes

What operating system and processor architecture are you using?

Macos

What did you do?

When using bzlmod support and go_deps being read from go.mod users still need to add manually direct dependencies to the use_repo rule. When running gazelle it will warn us when those are out of sync and give us a buildozer command to update it.

What did you expect to see?

Gazelle should be able to add this without users having to run the buildozer command. Alternatively rules_go should be able to add the direct dependencies as determined by go.mod without user intervention.

What did you see instead?

I have to run 3 commands to get everything to work:

go get $random_module # get the go module
bazel run //:gazelle  # adds dependency in BUILD file
buildozer 'use_repo_add @gazelle//:extensions.bzl $random_module' //MODULE.bazel:all  # adds the repo

With my proposal we could limit it to 2:

go get $random_module # get the go module
bazel run //:gazelle # adds dependency in BUILD file and repo in MODULE.bazel

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions