I have a boolean expression in string format, example:
name := "Fred"
type := "Person"
I want to evaluate this expression as true or false.
exp := "(name == Fred) && (type == Person)"
Eventually, I would like to be able to execute conditional statements such as:
if (exp) {
...
}
However, from research this is not something Go supports out of the box. I have seen suggestions on using AST to parse and evaluate. But, I am fairly new to go and especially AST, thus not sure how to go about that. Can someone please provide any guidance on how I may go about evaluating a string boolean expression? I have not come across any packages that support this entirely.