Skip to content

Latest commit

 

History

History
75 lines (63 loc) · 1.76 KB

README.md

File metadata and controls

75 lines (63 loc) · 1.76 KB

GoDeno

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.

Usage

  1. Create a new Go class
  2. Create a new WASM instance with the importObject on the new Go object.
  3. 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!

Go FS implementation

  • 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

Go Process implementation

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