i want to use like this:
js code:
let gomodule=require("./gomod.node");
gomodule.func(
function( fromGoObj){
console.info(fromGoObj)
}
);
then how can i write go code?
Your project has been very helpful to me. Thank you very much
i want to use like this:
js code:
let gomodule=require("./gomod.node");
gomodule.func(
function( fromGoObj){
console.info(fromGoObj)
}
);
then how can i write go code?
Your project has been very helpful to me. Thank you very much
I'm still developing the js_native_api.go to allow for this use-case, but it's not there just yet. Ultimately you'd need to make use of the napi_call_function / napi.CallFunction API to do this.
This isn't finalized, but the Go portion would look a little something like this once that's added:
funcFuncCallback(envnapi.Env,infonapi.CallbackInfo)napi.Value{callbackInfo,_:=napi.GetCbInfo(env,info)jsCallback:=callbackInfo.Args[0]fromGoObj,_:=napi.CreateObject(env)globalValue,_:=napi.GetGlobal(env)// this napi.CallFunction API does not exist yet:napi.CallFunction(env,globalValue,jsCallback,[]napi.Value{fromGoObj})}// func CallFunction(env napi.Env, recv napi.Value, args []napi.Value) (napi.Value, napi.Status)
Hey! Sorry for the super slow response on this.
I'm still developing the `js_native_api.go` to allow for this use-case, but it's not there just yet. Ultimately you'd need to make use of the `napi_call_function` / `napi.CallFunction` API to do this.
This isn't finalized, but the Go portion would look a little something like this once that's added:
```go
func FuncCallback(env napi.Env, info napi.CallbackInfo) napi.Value {
callbackInfo, _ := napi.GetCbInfo(env, info)
jsCallback := callbackInfo.Args[0]
fromGoObj, _ := napi.CreateObject(env)
globalValue, _ := napi.GetGlobal(env)
// this napi.CallFunction API does not exist yet:
napi.CallFunction(env, globalValue, jsCallback, []napi.Value{fromGoObj})
}
// func CallFunction(env napi.Env, recv napi.Value, args []napi.Value) (napi.Value, napi.Status)
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
i want to use like this:
js code:
let gomodule=require("./gomod.node");
gomodule.func(
function( fromGoObj){
console.info(fromGoObj)
}
);
then how can i write go code?
Your project has been very helpful to me. Thank you very much
Hey! Sorry for the super slow response on this.
I'm still developing the
js_native_api.goto allow for this use-case, but it's not there just yet. Ultimately you'd need to make use of thenapi_call_function/napi.CallFunctionAPI to do this.This isn't finalized, but the Go portion would look a little something like this once that's added: