go-wasm/simple/caller/main.go

24 lines
423 B
Go
Raw Normal View History

2019-08-06 16:03:11 +03:00
package main
import (
2019-08-20 04:13:53 +03:00
"fmt"
2019-08-06 16:03:11 +03:00
"log"
wasmgo "github.com/vedhavyas/wasm"
)
func main() {
2019-08-15 21:12:20 +03:00
b, err := wasmgo.BridgeFromFile("test", "./simple/prog/main.wasm", nil)
2019-08-06 16:03:11 +03:00
if err != nil {
log.Fatal(err)
}
2019-08-20 04:13:53 +03:00
init, done := make(chan bool), make(chan error)
go b.Run(init, done)
<-init
2019-08-20 04:25:01 +03:00
res, err := b.CallFunc("printWasm", &[]interface{}{"Hello from Go"})
2019-08-20 04:13:53 +03:00
fmt.Println(res, err)
err = <-done
fmt.Println("wasm exited", err)
2019-08-06 16:03:11 +03:00
}