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
Go
class - Create a new WASM instance with the
importObject
on the newGo
object. - 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"
func main() {
js.Global().Set("export1", "Hello!");
<- make(chan bool)
}
import Go from "mod.ts"
let go = new Go();
let wasm = await WebAssembly.instantiate(Deno.readFileSync("code.wasm"), go.importObject);
let promise = go.run(wasm.instance);
let value = 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