Go to file
Rémi Calixte 422fa73927
Basic Types
2018-12-10 16:44:12 -05:00
.circleci Add test matrix for Python versions 2018-12-10 10:28:17 -07:00
script Basic Types 2018-12-10 16:44:12 -05:00
test Add test matrix for Python versions 2018-12-10 10:28:17 -07:00
.gitignore Interpreter lifecycle 2018-12-07 14:47:44 -05:00
Gopkg.lock Basic Types 2018-12-10 16:44:12 -05:00
Gopkg.toml Basic Types 2018-12-10 16:44:12 -05:00
LICENSE Initial commit 2018-11-05 13:05:33 -05:00
README.md Update error API for high level to expose Go error 2018-12-06 17:05:44 -07:00
boolean.go Basic Types 2018-12-10 16:44:12 -05:00
boolean_test.go Basic Types 2018-12-10 16:44:12 -05:00
dict.go Basic Types 2018-12-10 16:44:12 -05:00
dict_test.go Basic Types 2018-12-10 16:44:12 -05:00
helper.go Basic Types 2018-12-10 16:44:12 -05:00
high_level_layer.go Fix: import fmt 2018-12-07 11:51:35 -05:00
integer.go Basic Types 2018-12-10 16:44:12 -05:00
integer_test.go Basic Types 2018-12-10 16:44:12 -05:00
lifecycle.go Interpreter lifecycle 2018-12-07 14:47:44 -05:00
lifecycle_test.go Interpreter lifecycle 2018-12-07 14:47:44 -05:00
list.go Basic Types 2018-12-10 16:44:12 -05:00
macro.c Basic Types 2018-12-10 16:44:12 -05:00
macro.h Basic Types 2018-12-10 16:44:12 -05:00
object.go Basic Types 2018-12-10 16:44:12 -05:00
tuple.go Basic Types 2018-12-10 16:44:12 -05:00
type.c Basic Types 2018-12-10 16:44:12 -05:00
type.h Basic Types 2018-12-10 16:44:12 -05:00
unicode.go Basic Types 2018-12-10 16:44:12 -05:00
variadic.c Basic Types 2018-12-10 16:44:12 -05:00
variadic.h Basic Types 2018-12-10 16:44:12 -05:00

README.md

go-python3

Golang bindings for the C-API of CPython-3.

This package provides a go package named "python" under which most of the PyXYZ functions and macros of the public C-API of CPython have been exposed. Theoretically, you should be able use https://docs.python.org/3/c-api and know what to type in your go program.

API

Some functions mix go code and call to Python function. Those functions will return and int and error type. The int represent the Python result code and the error represent any issue from the Go layer.

Example:

func PyRun_AnyFile(filename string) open filename and then call CPython API function int PyRun_AnyFile(FILE *fp, const char *filename).

Therefore its signature is func PyRun_AnyFile(filename string) (int, error), the int represent the error code from the CPython PyRun_AnyFile function and error will be set if we failed to open filename.

If an error is raise before calling th CPython function int default to -1.