I am using tinygo to generate a wasm for simple function:
//export onInput
func onInput() map[string]interface{} {
return map[string]interface{}{
"key": 60,
"remove": 1,
}
}
Then I am using wasm target to build using tinygo, as:
tinygo build -o main.wasm -target wasm ./main.go
And when I call the method wasm.exports.onInput()
I am getting a number such as: 102752
How would I get the JS object as a return value like:
{ key: 60, remove: 1 }
// Or array [60, 1] if possible
Note:
The tinygo documentation says:
The WebAssembly target does not return variables directly that cannot be handled by JavaScript (see above about i64, also struct, i64, multiple return values, etc). Instead, they are stored into a pointer passed as the first parameter by the caller.
If that's the cause of the issue, how would I pass the return value as a pointer from javascript?
Edit
I wasn’t able to figure out how I would return any of: arrays, strings or maps from a go function. I would settle for any of the above.