SWIG:从Python调用Go

Can SWIG be used to call Go functions from Python?

The Go examples I have seen in SWIG all seem to call C/C++ functions from Go.

One of the Go compilers produces C (cgo). I have never looked at it, but there may be a path to calling those functions from Python using SWIG.

Also their is Cython, which converts a form-of-Python to C, so that may provide another more direct path by combining the two with C as the glue, and without SWIG.

I was told by a Cython user at Python WM, that with care, Cython can produce C which needs no 'magic' run-time to work. Their technique is to use Cython mechanisms e.g.cdef, to make their Python closer to C. By changing the Cython source then iteratively looking at the Cython output, they said they can cause Python run-time to 'disappear', and reach 'pure' C. This is not ideal, but might be better than nothing.

So you might be able to use that mechanisms to wrap around Go functions which have been compiled to C. BUT this approach would restrict you to using Cython, which might be too much of a constraint.