I've been trying to find a way to set cfg on rules from the attr level.
)
config_setting(
    name = "custom_define_config1",
    define_values = {
        "foo": "bar",
    },
)
config_setting(
    name = "custom_define_config2",
    define_values = {
        "foo": "baz",
    },
)
We can conditionally build the library with --define foo=bar or --define foo=baz. However, I want to define these on certain targets.
go_test(
   name = "test_with_config1",
   srcs = ["config_test.go"],
   embed = [":go_default_library"],
   cfg = {"foo": "bar"},
)
go_test(
   name = "test_with_config2",
   srcs = ["config_test.go"],
   embed = [":go_default_library"],
   cfg = {"foo": "baz"},
)
How can this be achieved without forking rules_go with complicated starlark transitions?
Background / resources I've read: