expr
expr copied to clipboard
Normalizing exported struct fields
Hey there :) Please consider the following:
type Instance struct {
PublicAddress string
PrivateAddress string
Name string
Labels map[string]string
}
program, err := expr.Compile(target, expr.Env(Instance{}), expr.AsBool())
.......
I can now evaluate the following expression Name == "foobar" but not name == "foobar" since Name is an exported field and thus starts with a capital letter. What would be the best practice here to be able to use lowercase/case insensitive field names in the expressions?
Thanks
What about adding expr.Option for case insensitive vars and names?
expr.CaseInsensitive()
That would be handy :)
PR are welcome ;)
Haha yep, i'm gonna look into it :)
Now Expr has expr:"name" tags!