rename to examples
This commit is contained in:
3 files changed
+3
-3
No files matched your search
@@ -0,0 +1,26 @@
|
||||
// +build js,wasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"syscall/js"
|
||||
)
|
||||
|
||||
func addition(this js.Value, args []js.Value) interface{} {
|
||||
log.Println("In WASM", args)
|
||||
a, b := args[0].Int(), args[1].Int()
|
||||
return a + b
|
||||
}
|
||||
|
||||
func main() {
|
||||
ch := make(chan bool)
|
||||
|
||||
// register functions
|
||||
fun := js.FuncOf(addition)
|
||||
js.Global().Set("addition", fun)
|
||||
|
||||
res := js.Global().Get("proxy").Invoke(1, 2)
|
||||
log.Printf("1 + 2 = %d\n", res.Int())
|
||||
<-ch
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
Reference in new issue
Block a user