go-wasm/simple/prog/main.go

24 lines
360 B
Go
Raw Normal View History

2019-08-06 16:03:11 +03:00
// +build js,wasm
package main
import (
"fmt"
"syscall/js"
)
2019-08-07 13:47:59 +03:00
func printWasm(this js.Value, v []js.Value) interface{} {
2019-08-06 16:03:11 +03:00
fmt.Println("Hello from WASM", v)
2019-08-07 13:47:59 +03:00
return nil
2019-08-06 16:03:11 +03:00
}
func main() {
2019-08-07 13:47:59 +03:00
c := make(chan struct{}, 0)
fmt.Println("WASM Go Initialized")
// register functions
js.Global().Set("printWasm", js.FuncOf(printWasm))
2019-08-06 16:03:11 +03:00
fmt.Println("Done...")
2019-08-07 13:47:59 +03:00
<-c
2019-08-06 16:03:11 +03:00
}