Lab 11: WebAssembly Go
Overview
Step 1: WASM Compilation Basics
# Compile Go to WASM
GOOS=js GOARCH=wasm go build -o app.wasm main.go
# Check binary size
wc -c app.wasm # bytes
ls -lh app.wasm # human-readable
# The WASM runtime shim (copy to serve with HTML)
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" .
# Minimize size with tinygo (optional)
# tinygo build -o app.wasm -target=wasm main.goStep 2: Minimal WASM Module
Step 3: DOM Interaction with syscall/js
syscall/jsStep 4: HTML Host Page
Step 5: Bidirectional Calls
Step 6: WASM Binary Size Analysis
Step 7: Serve WASM Locally
Step 8: Capstone — Compile and Measure
Summary
Aspect
Value
Notes
Last updated
