Tested with Go 1.22.1, Bun 1.0.30, Deno 1.41.2, starlark-go v0.0.0-20240314022150-ee8ed142361c.
- Open this repo in devcontainer, e.g. using Github Codespaces. Type or copy/paste following commands to devcontainer's terminal.
cd
into the folder of this example:
cd browser-and-deno
- Install starlark-go:
go get "go.starlark.net/starlark"
- Compile the example:
GOOS=js GOARCH=wasm go build -o main.wasm main.go
- Copy the glue JS from Golang distribution to example's folder:
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" .
- Run simple HTTP server to temporarily publish project to Web:
python3 -m http.server
Codespace will show you "Open in Browser" button. Just click that button or obtain web address from "Forwarded Ports" tab.
- As
index.html
and a 9.9M-sizedmain.wasm
are loaded into browser, refer to browser developer console to see the results.
Impossible yet due to golang/go#59605.
- Install Bun:
curl -fsSL https://bun.sh/install | bash
- Run with Bun:
~/.bun/bin/bun bun.js
- Install Deno:
curl -fsSL https://deno.land/x/install/install.sh | sh
- Run with Deno:
~/.deno/bin/deno run --allow-read --allow-net deno.js
Perform your own experiments if desired.