cgo: examples
This commit is contained in:
18
_demo/cgopython/cgopython.go
Normal file
18
_demo/cgopython/cgopython.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#cgo pkg-config: python3-embed
|
||||
#include <Python.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
// TODO(lijie): workaround for cgo pkg-config not working
|
||||
const (
|
||||
LLGoPackage = "link: $LLGO_LIB_PYTHON; $(pkg-config --libs python3-embed)"
|
||||
)
|
||||
|
||||
func main() {
|
||||
C.Py_Initialize()
|
||||
defer C.Py_Finalize()
|
||||
C.PyRun_SimpleString(C.CString("print('Hello, Python!')"))
|
||||
}
|
||||
Reference in New Issue
Block a user