-
-
Notifications
You must be signed in to change notification settings - Fork 462
Closed
Labels
Description
type X struct {}
func (x *X) HelloCtx(ctx context.Context, text string) error {
fmt.Println("hello:", text)
return nil
}
Convey("test goexr engine", t, func() {
env := map[string]any{
"_goctx_": context.TODO(),
"_g_": map[string]*X{
"rpc": &X{},
},
"text": "gonghuan",
}
exprStr := `
let v = _g_.rpc.HelloCtx(_goctx_, text);
`
program, err := expr.Compile(exprStr, expr.Env(env), expr.WithContext("_goctx_"))
So(err, ShouldBeNil)
_, err := expr.Run(program, env)
So(err, ShouldBeNil)
})
it will fail call HelloCtx
with
Expected: nil
Actual: 'reflect: Call with too few input arguments (3:20)
| let v = _g_.rpc.HelloCtx(text);
but if level up "rpc" to env map like this:
// this is ok
env := map[string]any{
"_goctx_": context.TODO(),
"_g_": &X{},
"text": "gonghuan",
}
// wrong
env := map[string]any{
"_goctx_": context.TODO(),
"_g_": map[string]*X{
"rpc": &X{},
},
"text": "gonghuan",
}
is seems like a bug? help pls...