A simple port of Golang's JS/WASM glue code to Deno in TypeScript. Credit to the Go team for their amazing work on getting Go working in WASM!
Requires --unstable flag. Permissions flags are also required for filesystem usage.
- Create a new
Goclass - Create a new WASM instance with the
importObjecton the newGoobject. - Run
go.run(wasmInstance)with your WASM instance.
The go instance has an exports object for any objects that Go exposed on the js.Global() object.
Example Code:
package main
import"syscall/js"funcmain() {
js.Global().Set("export1", "Hello!");
<-make(chanbool)
}importGofrom"mod.ts"letgo=newGo();letwasm=awaitWebAssembly.instantiate(Deno.readFileSync("code.wasm"),go.importObject);letpromise=go.run(wasm.instance);letvalue=go.exports.export1;console.log("Go says: "+value);//Go says: Hello!- fs.open
- fs.close
- fs.mkdir
- fs.readdir
- fs.stat
- fs.lstat
- fs.fstat
- fs.unlink (Uses
Deno.remove()) - fs.rmdir
- fs.chmod
- fs.fchmod (Not native API)
- fs.chown
- fs.fchown (Not native API)
- fs.lchown (Deno does not support lchown.)
- fs.utimes
- fs.rename
- fs.truncate
- fs.ftruncate
- fs.readlink
- fs.link
- fs.symlink
- fs.fsync
- fs.read
- fs.write
As of now, Deno does not have ways to get the GID or umask.
- process.getuid
- process.getgid
- process.geteuid
- process.getegid
- process.getgroups
- process.pid
- process.ppid
- process.umask (Unstable API)
- process.cwd
- process.chdir