Calling Go functions from Erlang
April 2018: This is a work in progress.
Allow Erlang programs to call Go functions with minimum inconvenience.
It's certainly possible for an Erlang program to call a function written in Go, but it's frustratingly difficult. You must write an Erlang NIF in C, translate Erlang terms into Golang data structures, and then use CGO to call the Go function.
For many projects this overhead is too big, and most developers would just re-implement the Golang code in Erlang. The aim of this project is to make the process simple enough that calling Go from Erlang is easy.
https://punch.photoshelter.com/image/I0000ZvleumhOmDo
This work is saved in branch nif-plugin-experiment
.
ergo
) provided various functions to call into Go.Call
function.Call
looked up the target function (a named function within a Golang plugin) and translatedThis was abandoned because Golang does not support
a Shared Object (-buildmode=c-shared
) calling a Golang plugin.
An Erlang port is a common way to call out to external programs from Erlang, but is way too heavyweight for my purposes.
Using a technique such as Erlang C Nodes or JInterface is an interesting idea, but doesn't fit in with the lightweight approach I'm looking for.