how to make a runtime environment for Go to/on the Python Interpreter?

443 views Asked by At

so if it possible to make it? just like what igo(https://code.google.com/p/jgo/) does! it provide a complete compiler and runtime environment for the Go programming language to/on the Java Virtual Machine!

if possible! what i need to learn or know?

what i want to do is just writing a python package to make it possible to run python interpreter!

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

There are 1 answers

0
Joonazan On

You could translate go code into Python bytecode, but it wouldn't make a lot of sense. The same Go program would just run slower.

You'd need to learn python bytecode and writing compilers.

If you just want to compile and run Go code from Python you can use Python's standard library: Calling an external command in Python

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