我的问题如下:
- 我在一台机器上有一个 Go 二进制文件。
- 我需要从该二进制文件编译一个外部的 .go 文件。
- 一旦编译完成,我需要将已编译的 go 文件链接到当前二进制文件中,以便我可以使用刚编译的 Go 代码。
你认为这可能吗?
我进行了一些研究,似乎不可能,但我可能忽略了某些东西。
谢谢 :)
第一个 Go 二进制文件将包含类似以下内容:
func main() {
// Here I need to compile an external go file (or package) which contains
// The definition of runFoo()
// Once the file/package is compiled and linked I need to call the compiled code
runFoo()
// Continue the execution process normally here
}