bazel-contrib / bazel-gazelle

Gazelle is a Bazel build file generator for Bazel projects. It natively supports Go and protobuf, and it may be extended to support new languages and custom rule sets.
Apache License 2.0
1.19k stars 378 forks source link

Skip over godebug lines in go.mod/go.work files #1946

Open zecke opened 1 week ago

zecke commented 1 week ago

Go 1.21 introduced support for godebug lines in go.mod and go.work files. Skip over these lines instead of failing

Related #1945

What type of PR is this?

Uncomment one line below and remove others.

Bug fix Feature Documentation Other

What package or component does this PR mostly affect?

For example:

language/go cmd/gazelle go_repository all

What does this PR do? Why is it needed?

Which issues(s) does this PR fix?

Fixes #

Other notes for review

zecke commented 4 days ago

What if we handle this like the go_embed directive and update the x_defs?

fmeum commented 4 days ago

Yeah, I'm all for treating this exactly like Go itself does, I just don't know how it's wired up exactly. Happy to review a change that goes beyond skipping.

zecke commented 4 days ago

Yeah, I'm all for treating this exactly like Go itself does, I just don't know how it's wired up exactly. Happy to review a change that goes beyond skipping.

From what I can tell is that one of the challenges of rules_go is that the builder is not using go build. Which means we don't benefit from some of the checks (e.g. checking if the flag exists, if one can link an internal package).