An experiment using Go 1.5 buildmode to compile shared C libraries, and to subsequently access them through NodeJS bindings via node-ffi.
Simply put, let's try calling Go functions from JavaScript.
Tested with go1.9.1, and Node v7.8.0.
-
Download, and install the package:
go get github.com/mrsaints/go-node-ffi
-
Install NPM dependencies:
yarn // OR... npm install
yarn build
// OR...
go build -buildmode=c-shared -o go-node-ffi.soTinker with the sample file go-node-ffi.js, and run:
yarn start
// OR...
node go-node-ffi.jsEnable verbose logging:
export DEBUG="ref,ref:struct"
Now, run the program (see above).