Open rfyiamcool opened 1 year ago
happen error
GetFunction Missing 4 argument(s) when calling the function; Expected 5 argument(s), received 1
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.
add
replace
4 <nil> Missing 4 argument(s) when calling the function; Expected 5 argument(s), received 1
same question
Summary
happen error
Additional details
I use the code to build wasm by tinygo.
go code
the function
add
run successfully, but functionreplace
failed to run.