This library provides a Go API for different Web APIs for WebAssembly target.
It's in an active development, but an API will be carefully versioned to avoid breaking users. Use Go dependency management tools to lock a specific version.
More information about Go's WebAssembly support can be found on Go's WebAssembly wiki page.
Features:
syscall/js
)LocalStorage
and SessionStorage
net
-like library for WebSockets
wasm-server
for fast prototypingPull the library and install wasm-server
(optional):
go get -u github.com/dennwc/dom
go install github.com/dennwc/dom/cmd/wasm-server
Run an example app:
cd $GOPATH/src/github.com/dennwc/dom
wasm-server
Check result: http://localhost:8080/
The source code is recompiled on each page refresh, so feel free to experiment!
If you are using Visual Studio Code, you can use workspace settings to configure the environment variables for the go tools.
Your settings.json file should look something like this:
{
"go.toolsEnvVars": { "GOARCH": "wasm", "GOOS": "js" }
}