0

My go code

package main

import "fmt"

func main() {
  fmt.Println("Hello Web Assembly!")
}

Then I build the wasm file using the following command

GOOS=js GOARCH=wasm go build -o main.wasm

I got main.wasm file. Then I installed wasmtime to run the wasm files. When I tried to run the wasm file with wasmtime, I'm getting the following error,

Error: failed to run main module main.wasm

Caused by: >0: failed to instantiate "main.wasm" >1: unknown import: go::debug has not been defined

My Go version: 1.20, My wasmtime version: wasmtime-cli 9.0.4, OS: Mac

This is just a simple example. Is there anything, I'm doing wrong? TIA.

ArulRulzz
  • 87
  • 6

1 Answers1

0

You'll need to compile to wasi instead of wasm if you wanna run this using wasmtime.

Tuong Le
  • 18,533
  • 11
  • 50
  • 44