/wasm-go

wasm-go is a module that is designed to compile a WebAssembly module from Go. There is a publication for this repository which can be found at https://pascalallen.medium.com/how-to-compile-a-webassembly-module-from-go-a9ed5f831582.

Primary LanguageGo

wasm-go

wasm-go is a module that is designed to compile a WebAssembly module from Go. There is a publication for this repository which can be found here.

Prerequisites

WebAssembly Compilation Steps

Compile the project's Go module to WebAssembly

cd app/ && GOOS=js GOARCH=wasm go build -o ../public/app.wasm

Copy the compiled JavaScript WebAssembly support file to the project

cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ../public/app.js

Run the project's web server from project root

go run webserver.go

Navigate to http://localhost:9990/, open the JavaScript debug console, and you should see the output. You can modify the program, rebuild app.wasm, and refresh to see new output.