You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ljzhou1577
changed the title
map[string]interface{}指针传到dataContext,在做 if 字段判断一直出现panic
map[string]interface{}指针传到dataContext,在做 if 字段判断一直出现panic,求解
May 6, 2022
const ( data_rule = \
rule "data rule" "a test" salience 10
begin
println(up["status"])
if up["status"] == 1{
return true
}else{
return false
}
end `
)
func Test_check(t *testing.T) {
upDataMap := make(map[string]interface{})
busiz1 := []byte(
{"reference_id":2073666894,"status":1}
)decoder1 := json.NewDecoder(bytes.NewReader(busiz1))
err := decoder1.Decode(&upDataMap)
if err != nil {
fmt.Printf("Unmarshal error, err: %+v", err)
return
}
dataContext := context.NewDataContext()
dataContext.Add("up", &upDataMap)
ruleBuilder := builder.NewRuleBuilder(dataContext)
err1 := ruleBuilder.BuildRuleFromString(data_rule)
if err1 != nil {
panic(err1)
}
eng := engine.NewGengine()
err2 := eng.Execute(ruleBuilder, true)
if err2 != nil {
panic(err2)
}
fmt.Printf("Finish")
}`
The text was updated successfully, but these errors were encountered: