我想为现有的(第三方)Python 模块编写 golang 绑定(bind)。
目的是我想使用 Python 模块在 Golang 中提供的 API。
我已经找到了 Python 的 C API 的 golang 绑定(bind)(go-python3 用于 py3 和 go-python 用于 py2),但我仍然没有弄清楚如何将相对复杂的 Python 模块转换为 Golang(即如何处理在 python 中寻找不安全的输入和返回等)。
什么是好方法?该领域是否有任何预先存在的工具? Python代码的Golang绑定(bind)有什么好的例子吗? (我找不到很多 tbh)。
最佳答案
I want to use the API that the Python module provides in Golang.
最近在 Python and Go : Part I - gRPC 的“Miki Tebeka”中详细介绍了从 Go 调用 Python。 .
您可以在
ardanlabs/python-go/grpc
中查看示例但是,如 their next two articles 所示, 你也可以:
完整示例:
ardanlabs/python-go/pyext
.
关于python - 为 python 模块创建 golang 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63510031/