NewIntType==1 will be false, How to make it true.
import (
"fmt"
"testing"
"github.com/antonmedv/expr"
)
type newIntType int
const (
newIntTypeA newIntType = 1
newIntTypeB newIntType = 2
)
func TestCalBool1(t *testing.T) {
type XX struct {
NewIntType newIntType
}
val := &XX{
NewIntType: newIntTypeA,
}
s := "NewIntType==1"
fmt.Println(CalBool(s, val))
}
func CalBool(input string, env interface{}) (bool, error) {
output, err := cal(input, env)
if err != nil {
return false, err
}
if val, ok := output.(bool); ok {
return val, nil
}
return false, err
}
func cal(input string, env interface{}) (interface{}, error) {
return expr.Eval(input, env)
}