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
|
|
|
|
res, err := b.CallFunc("printWasm", &[]interface{}{"success call"})
|
|
|
|
fmt.Println(res, err)
|
|
|
|
err = <-done
|
|
|
|
fmt.Println("wasm exited", err)
|
2019-08-06 16:03:11 +03:00
|
|
|
}
|