JS + wasm in Go (1.13.1)
Disclaimer: It's not an example of how it should be done. My goal was to play with wasm API in Go and to implement as much logic as I can in wasm.
Go WebAssembly
https://github.com/golang/go/wiki/WebAssembly
Configure IntelliJ IDEA
IntelliJ IDEA -> Preferences -> Languages & Frameworks -> Go -> Build Tags & Vendoring
OS: js
Arch: wasm
https://github.com/golang/go/wiki/Configuring-GoLand-for-WebAssembly
Go Wasm tutorials
- Go WebAssembly Tutorial - Building a Calculator Tutorial
- Compiling Go to WebAssembly Examples of which libraries to import in order to compile Go
- Some changes in how to register go functions
Use
FuncOf
instead ofNewCallback
- Go 1.11: WebAssembly for the gophers
Good explanation on different API methods of
js.Value
How to install Go
https://golang.org/doc/install
How to test Go
-
- You need
go_js_wasm_exec
in your$PATH
, and you need nodejs installed to run the "node" binary.
- You need
-
https://stackoverflow.com/a/54919732
GOOS=js GOARCH=wasm go test -exec="node $(go env GOROOT)/misc/wasm/wasm_exec"