DEV Community

Cover image for Calling Rust code from Go - the Gambiarra way

Calling Rust code from Go - the Gambiarra way

Gabriel Grubba on April 12, 2023

Did you know that Rust has been voted the 'most loved programming language' for five years in a row by the Stack Overflow community? It's no wond...
Collapse
 
avelino profile image
Thiago Avelino

Your example using exec you are calling binary, it would not matter if it was written in rust or any other language

one way to call "functions" of a language inside Go is using the plugin, where you load the operating system library (files .so) and don't execute the binary as in your example above

I am using this plugin approach in prestd, here is a thread discussing how it works

Collapse
 
grubba profile image
Gabriel Grubba • Edited

Your example using exec you are calling binary, it would not matter if it was written in rust or any other language

Yes! this was mostly the example that steped upon, you are 100% correct, any compiled language should do the trick.

Never seen this before go-plugin, will check it out! Also loved the prest project
thanks a lot for the comment!

Collapse
 
avelino profile image
Thiago Avelino

Come contribute with us \o/, we need more people helping the project evolve