douyue8191 2019-06-27 08:16
浏览 89

以编程方式编译go源文件

I would like to build a Go server which receives Go source code from a client such as a react application and then compiles this code.

Can someone provide a clear explanation of steps to achieve this in Go and provide the Go packages that are used to achieve this and if possible provide example code?

  • 写回答

1条回答 默认 最新

  • du27271 2019-06-27 10:56
    关注

    You can always save the code to disk and use the Go tooling to run the code via the os/exec package. Go would need to be installed.

    Or you use a docker container with Go to run the code.

    If that is not what you had in mind I suggest you look at how the Go tooling is doing it. It's all open source: https://github.com/golang/. But that'll probably be a big rabbit hole to go down.


    That being said, running code you get from the web is a major security risk. So beware you properly secure that by running in a sandbox or securing the way the code is submitted. Best both.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据