initial commit
This commit is contained in:
4 files changed
+218
No files matched your search
@@ -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)
|
||||
}
|
||||
@@ -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{})
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
Reference in new issue
Block a user