Knetic / govaluate

Arbitrary expression evaluation for golang
MIT License
3.75k stars 503 forks source link

Can the expression support arrays or slices as input parameters? #188

Open yaduomo-1990 opened 1 year ago

yaduomo-1990 commented 1 year ago

like this:

expr4, err := govaluate.NewEvaluableExpression("dept_id in (dept_arr)")
    assert.Nil(t, err)
    parameters = make(map[string]interface{})
    parameters["dept_id"] = 20
    arr := make([]int, 3)
    arr[0] = 10
    arr[1] = 20
    arr[2] = 30
    parameters["dept_arr"] = arr
    // or-------------------------------
    parameters["dept_arr"] = []int{10,20}
    result, err = expr4.Evaluate(parameters)
    assert.Nil(t, err)
    fmt.Println("----------------")
    fmt.Println(result)