【问题标题】:how to make a runtime environment for Go to/on the Python Interpreter?如何为 Go to/on Python Interpreter 创建运行时环境?
【发布时间】:2013-12-06 09:19:30
【问题描述】:

所以如果可以的话?就像 igo(https://code.google.com/p/jgo/) 所做的一样!它为 Java 虚拟机上的 Go 编程语言提供了完整的编译器和运行时环境!

如果可能的话!我需要学习或知道什么?

我想做的只是写一个python包,让它可以运行python解释器!

from mypackage import Run
Run('path to go application')

【问题讨论】:

  • 你到底要什么?用 Python 编写的 Go 实现?将 Go 运行时嵌入到另一个程序中?还有什么?
  • @JamesHenstridge 用python写一个go运行时环境

标签: python go interpreter runtime-environment


【解决方案1】:

您可以将 go 代码翻译成 Python 字节码,但这没有多大意义。同一个 Go 程序只会运行得更慢。

你需要学习 python 字节码和编写编译器。

如果你只是想从 Python 编译和运行 Go 代码,你可以使用 Python 的标准库:Calling an external command in Python

from subprocess import check_output
print(check_output(["go", "run", "file.go"]))

【讨论】:

    猜你喜欢
    • 2018-09-24
    • 2019-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-11
    • 1970-01-01
    • 2020-04-07
    • 1970-01-01
    相关资源
    最近更新 更多