PaesslerAG / gval

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

Without space after && leading error #63

Closed Ovi3 closed 2 years ago

Ovi3 commented 3 years ago
package main

import (
    "fmt"
    "github.com/PaesslerAG/gval"
)

func main() {
    vars := map[string]interface{}{"name": true}

    value, err := gval.Evaluate("true&&name", vars)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println(value)

    value, err = gval.Evaluate("true&& name", vars)
    if err != nil {
        fmt.Println(err)
    }

    fmt.Println(value)
}

runing result:

parsing error: true&&name    - 1:8 unknown operator &&n
<nil>
true

My expected result is the first expression also working fine.

generikvault commented 3 years ago

yes this is because of the operator in this operator should probably be a function in v2

Ovi3 commented 3 years ago

My current workaround is replacing "&&" to " && ".

By the way, any plan with v2 ?

generikvault commented 3 years ago

Probably a version with generic in and output types next year. Depends on wether it works the way I envision it.

Ovi3 commented 2 years ago

Cool. Thanks for your reply.