go code (foo.go) compiled into a shared library and a c header (foo.h) is generated.
For calling go from c, please see here
The code below shows two ways of passing string parameter to go function:
- Using GoString structure as argument, without making a copy in go code: no conversion to go string needed.
- Using c_char_p as argument, making a copy in go code when converting to go string.
When using the first method without the copy, I don't know how python will do the memory management with the pointer passed into go. So the second method is preferred.