Notice that the name of the rule is fun_rule and it is only named via the variable. We don't provide the rule a name attribute. Now, if we invoke the rule with a non-existent attribute, Bazel throws an error:
fun_rule(name = "example", fake_attr = "hello")
$ bazel build //:example
ERROR: /app/BUILD:3:10: //:example: no such attribute 'fake_attr' in 'fun_rule' rule
As you can see, Bazel was able to understand the left hand variable name of the rule. If we were to transfer to over to starlark-go, how can we get the left-hand variable name given the builtin method?
In Bazel, we define a rule as:
Notice that the name of the rule is
fun_rule
and it is only named via the variable. We don't provide the rule a name attribute. Now, if we invoke the rule with a non-existent attribute, Bazel throws an error:As you can see, Bazel was able to understand the left hand variable name of the rule. If we were to transfer to over to starlark-go, how can we get the left-hand variable name given the builtin method?