PaesslerAG / gval

Expression evaluation in golang
BSD 3-Clause "New" or "Revised" License
727 stars 82 forks source link

parameter not support map[int]int ? #22

Closed zhangziang closed 5 years ago

zhangziang commented 5 years ago

The following code will panic

    value,err := gval.Evaluate(`a[0] + a[2]`, map[string]interface{}{
        "a":map[int]int{0:1,2:1},
    })
generikvault commented 5 years ago

fixed it and added your example to the test cases

zhangziang commented 5 years ago

@generikvault If the map index‘s type is int32 or int64 or float32 … will get a err.

generikvault commented 5 years ago

@zhangziang Yes, sorry thats not supported yet. You can override the VariableSelector in your own project or extend the functionallity in gval via pull request.

zhangziang commented 5 years ago

ok, thanks. Is there some references can help me understand this project?

generikvault commented 5 years ago

There's is godoc with an enxample: https://godoc.org/github.com/PaesslerAG/gval#VariableSelector