initial commit

This commit is contained in:
vedhavyas committed 2019-08-06 15:03:11 +02:00
commit d528eeada8
4 files changed
+218

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
package main
import "C"
import (
"fmt"
"log"
wasmgo "github.com/vedhavyas/wasm"
wasm "github.com/wasmerio/go-ext-wasm/wasmer"
)
func main() {
// Reads the WebAssembly module as bytes.
bytes, err := wasm.ReadBytes("./simple/prog/main.wasm")
if err != nil {
log.Fatal(err)
}
imports, err := wasmgo.Imports()
if err != nil {
log.Fatal(err)
}
// Instantiates the WebAssembly module.
instance, err := wasm.NewInstanceWithImports(bytes, imports)
if err != nil {
log.Fatal(err)
}
defer instance.Close()
fmt.Println(instance.Exports)
}
+18
View File
@@ -0,0 +1,18 @@
// +build js,wasm
package main
import (
"fmt"
"syscall/js"
)
func printWasm(v []js.Value) {
fmt.Println("Hello from WASM", v)
}
func main() {
js.Global().Set("printWasm", js.NewCallback(printWasm))
fmt.Println("Done...")
<-make(chan struct{})
}
BIN
View File
Binary file not shown.