Tested with Go 1.24.0, Bun 1.2.2, Deno 2.1.10, Expr v1.16.9.
-
Open this repo in devcontainer, e.g. using Github Codespaces. Type or copy/paste following commands to devcontainer's terminal.
-
Install Deno (also used as static HTTP server, as Ubuntu Noble has no Python installed by default):
curl -fsSL https://deno.land/install.sh | bash -s -- --yes
cd
into the folder of this example:
cd browser-and-deno
- Install expr:
go get github.com/expr-lang/expr
- 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 (note using
/lib/wasm/
because Go 1.24):
cp $(go env GOROOT)/lib/wasm/wasm_exec.js ./
- Run simple HTTP server to temporarily publish project to Web:
~/.deno/bin/deno run --allow-net --allow-read jsr:@std/http/file-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 14.7M-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
- Run with Deno:
~/.deno/bin/deno run --allow-read --allow-net deno.js
Perform your own experiments if desired.