Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Import Go from Python the "right" way
go build -buildmode=c-archive .
python hello_build.py
python -c "import _hello; _hello.lib.Hello()"
package main
import "C"
import "github.com/fatih/color"
//export Hello
func Hello() {
color.Green("Hello, 世界")
}
func main() {}
from cffi import FFI
ffibuilder = FFI()
ffibuilder.set_source("_hello", """
#include "hello.h"
""", extra_objects=["hello.a"])
ffibuilder.cdef("void Hello();")
if __name__ == "__main__":
ffibuilder.compile(verbose=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.