bytecodealliance / bytecodealliance/wasmtime-go
No compiled main function from file called
- Dominant language
- Go
- Stars
- 913
- Forks
- 100
- Avg merge
- 10m
- Merged PRs (30d)
- 1
Description
I am trying to run a program compiled into wasm from go. In Rust exists a [guide](https://docs.wasmtime.dev/examples-rust-wasi.html) for it, however, I have not found it in Go.
I have created the following hello.go file
```Go
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
```
And compile to `hello.wasm` using tiny go. Using `wasmtime hello.wasm` the correct output is expected.
Now i want to call it from my go code:
```Go
package main
import (
"log"
"github.com/bytecodealliance/wasmtime-go"
)
func main() {
store := wasmtime.NewStore(wasmtime.NewEngine())
module, err := wasmtime.NewModuleFromFile(store.Engine, "/home/arejula27/workspaces/go-lab/wasm/hello.wasm")
if err != nil {
panic(err)
}
linker := wasmtime.NewLinker(store.Engine)
linker.DefineModule(store, "", module)
hello, err := linker.GetDefault(store, "")
if err != nil {
panic(err)
}
_, err = hello.Call(store)
if err != nil {
log.Fatal(err)
}
}
```
With this code, no output is generated. Do you know how I can do it correctly?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.