DEV Community

Cover image for :Goarch! WASM
Malik Benkirane
Malik Benkirane

Posted on

3 2

:Goarch! WASM

cover image source: egghead.io

The tools

Getting started

import syscall/js
Enter fullscreen mode Exit fullscreen mode
$ GOARCH=wasm GOOS=js go build ...
Enter fullscreen mode Exit fullscreen mode

Setting values

js.Global()
js.Global().Set(varname, js.ValueOf(x))
Enter fullscreen mode Exit fullscreen mode

Console logging

println()
Enter fullscreen mode Exit fullscreen mode

Expose **callbacks**

Js.Global().Set(ftname, js.NewCallback(f))
Enter fullscreen mode Exit fullscreen mode

Interoperability

func f(i []js.Value) {
  // f(a), i[0]=a
  // f(a,b), i[0]=a, i[1]=b
  // ...
}
Enter fullscreen mode Exit fullscreen mode

Illustrations

to be continued

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay