When compiling Go to WebAssembly, the Go compiler assumes the
WebAssembly is going to run in a JavaScript environment. Hence a
wasm_exec.js
file is provided by the Go compiler and must be
used. However, WebAssembly can actually run everywhere. So we need to
use some hacks to make WebAssembly modules generated by the Go
compiler runnable everywhere. And that's where gowasmer
is useful.
gowasmer
is a port of the wasm_exec.js
file, for Go. It assumes
the WebAssembly runtime is
wasmer-go
.
Alternatively, to avoid using gowasmer
, you can compile your Go
program to WebAssembly with TinyGo as follows:
$ tinygo build -o module.wasm -target wasi .
See _example
directory.
$ go get github.com/mattn/gowasmer
MIT
Yasuhiro Matsumoto (a.k.a. mattn)