Interfacing Go and Elixir via WebAssembly

185
clicks
Interfacing Go and Elixir via WebAssembly

Source: yasoob.me

Type: Post

Yasoob Khalid encountered a situation where he needed to leverage Go code within an Elixir project. Direct interfacing, similar to how Rust code is interfaced using a NIF, was not available. He considered using Ports but then opted for a solution using WebAssembly System Interface (WASI), specifically with the help of Wasmex and guidance from Philipp Tessinow, the creator of Wasmex. The author outlines the steps required to compile Go code with Tinygo to a WASI target, run the resulting binary within an Elixir host, pass data into the WASI binary, and extract data from it. Although he recognizes there may be limitations as the complexity of the Go code increases, Khalid is satisfied with this solution for basic use cases and enjoys the flexibility it offers for his project.

© HashMerge 2024