You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"fmt""os"
wasmer "github.com/wasmerio/wasmer-go/wasmer"
)
funcmain() {
wasmBytes, _:=os.ReadFile("test.wasm")
engine:=wasmer.NewEngine()
store:=wasmer.NewStore(engine)
// Compiles the modulemodule, _:=wasmer.NewModule(store, wasmBytes)
// Instantiates the moduleimportObject:=wasmer.NewImportObject()
instance, _:=wasmer.NewInstance(module, importObject)
// Gets the `sum` exported function from the WebAssembly instance.sum, _:=instance.Exports.GetFunction("sum")
// Calls that exported function with Go standard values. The WebAssembly// types are inferred and values are casted automatically.result, _:=sum(5, 37)
fmt.Println(result) // 42!
}
~/study/wasm go run main.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x10038efbd]
goroutine 1 [running]:
main.main()
/Users/wanghua/study/wasm/main.go:24 +0x9d
exit status 2
Problem description:
I used tinygo to compile a wasm file, and an error occurred when I used wasmer-go to read, compile and execute the file again.
Steps to reproduce
main.go
wasm.go
Expected behavior
The sum function exists and it should return the correct result.
Actual behavior
JavaScript
Output:
Uncaught TypeError: window.sum is not a function at calculate (index.html:23:31) at HTMLButtonElement.onclick(index.html:36:35)
The text was updated successfully, but these errors were encountered: