GetFunction Missing 4 argument(s) when calling the function
rfyiamcool opened this issue · 2 comments
rfyiamcool commented
Summary
happen error
GetFunction Missing 4 argument(s) when calling the function; Expected 5 argument(s), received 1
Additional details
I use the code to build wasm by tinygo.
package main
func main() {
}
//go:export add
func Add(a, b int) int {
return a + b
}
//go:export replace
func Replace(a string) string {
return a + "..."
}
go code
package main
import (
"fmt"
"io/ioutil"
wasmer "github.com/wasmerio/wasmer-go/wasmer"
)
func main() {
wasmBytes, _ := ioutil.ReadFile("module.wasm")
engine := wasmer.NewEngine()
store := wasmer.NewStore(engine)
// Compiles the module
module, err := wasmer.NewModule(store, wasmBytes)
if err != nil {
panic(err)
}
wasiEnv, _ := wasmer.NewWasiStateBuilder("wasi-program").CaptureStdout().CaptureStderr().Finalize()
importObject, err := wasiEnv.GenerateImportObject(store, module)
if err != nil {
panic(err)
}
instance, err := wasmer.NewInstance(module, importObject)
if err != nil {
panic(err)
}
addfunc, _ := instance.Exports.GetFunction("add")
result, _ := addfunc(1, 3)
fmt.Println(result)
replace, _ := instance.Exports.GetFunction("replace")
result, err = replace("aaa")
fmt.Println(result, err)
}
the function add
run successfully, but function replace
failed to run.
4
<nil> Missing 4 argument(s) when calling the function; Expected 5 argument(s), received 1
dullduck commented
same question
879229629 commented
No other types supported ?