If you want to use a shared library that is statically known at compile time, you can simply use cgo . Read the documentation on how to do this exactly, but usually you specify some linker flags and a couple of commented lines. The following is an example of calling the bar() function from libfoo.so .
package example
You can also use cgo to access shared objects that are dynamically loaded at runtime. You can use dlopen() , dlsym() and dlclose() to open a shared library, get the address of one of the functions inside, and finally close the library. Note that you cannot do these things in Go, you need to write shell code in C that implements the necessary logic for you.
source share