问题描述
有什么方法可以从C#执行Go函数吗?对于Python,我将使用Ironpython为例.
Is there any way to execute a Go function from C#? For Python I would use Ironpython for example.
我知道我可以产生一个执行Go脚本的过程,但我真的不希望在可能的情况下使用这种解决方案.
I know that I could spawn a process to execute a Go script, but I don't really want to fallback to such a solution, if possible.
Google搜索没有显示任何内容,那么有什么方法可以使用API做到这一点?还是我必须回退到流程?
A Google search didn't reveal anything, so is there any way to do that using an API? Or do I have to fallback on processes?
推荐答案
我的答案现在不正确,因为Go自发布以来已更新.此stackoverflow线程将帮助您解决问题.
my answer is now not true, since Go has been updated since I posted. this stackoverflow thread will help you solve your problem.
原始答案:
我认为您找不到想要的东西会很幸运. Go是静态链接的和 C#不支持.
I don't think you're going to have much luck finding what you're looking for. Go is statically linked and C# doesn't support that.
在C#中,>编译的可执行文件并读取输出是我能想到的最简单的事情.
From C#, calling a pre-compiled executable and reading the output is the easiest thing I can think of.
这篇关于如何在C#中执行Go函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!