Skip to content

littledivy/godeno

Repository files navigation

Go <=> Deno

Write Deno plugins in Golang.

  • Experimental, Deno plugins itself are unstable
  • Build c-shared libraries of your Go code and call them in Deno.
  • Simple API and ready-made code gluing.

Usage

Write your Go -

// go_deno.go
import "C"

//export gofunc
func gofunc(arg string) {
    // do stuff here...
}

func main() {}

...build as a c-shared library

go build -buildmode=c-shared -o mygolib.so

...and load and call it from Deno

// go_deno.ts
import { GoDeno } from "./mod.ts";
let plugin = new GoDeno("./mygolib.so");
plugin.dispatch("gofunc", "JS arg");

Example

cd example/
go build -buildmode=c-shared -o hello.so
deno run -A --unstable ./hello.ts

LICENSE

MIT License. Contributions welcome.

Releases

No releases published

Packages

No packages published