govaluate: Unable to parse numeric value '.' to float64 when using a struct parameter.

When passing in an expression that contains a struct to NewEvaluableExpression, I’m getting “Unable to parse numeric value ‘.’ to float64” error.


// element.ShowCondition.Condition = "Survey.Element('q1').Row('r2').Selected()"
expression, err := govaluate.NewEvaluableExpression(element.ShowCondition.Condition)
if err != nil {
        return 0, e.SMSInvalidConditionError
}

Any ideas?

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 15 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Looking, that latest commit was made on Oct 22, 2017, and release on May 1, 2017. This library seems to be unsupported.

I’ve found alternative https://github.com/antonmedv/expr, which seems to be the best performing https://github.com/antonmedv/golang-expression-evaluation-comparison.

I have exactly the same problem. Seems like accessors are broken.

E.g. create expression “xyz.Name == ‘test’” and it will fail with Unable to parse numeric value ‘.’ to float64"

This will compile, but won’t evaluate correctly: “[xyz.Name] == ‘test’”


Update: looks like this is another, unrelated issue. Accessors are not implemented in 3.0.0 release (Apr 2017), but are present in master. I switched to master and “xyz.Name == ‘test’” indeed evaluates correctly.