To build an extension in Go, you need to create a new Go package, and then compile it into a shared library that can be loaded from other programming languages. Here are the basic steps:
main.go88 chars7 lines
Note the "//export" comment before the function definition. This tells the Go compiler to export the function for use in other languages.
main.go62 chars2 lines
This will create a shared library called "myextension.so" that contains your exported functions.
main.go99 chars6 lines
Note that the function name in Python matches the exported function name in Go (without the "//export" comment).
That's it! You should now be able to build and use your Go extension in other programming languages.
gistlibby LogSnag