-5

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?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Neo
  • 717
  • 2
  • 11
  • 26
  • 7
    No, we're not going to design, write, and implement your entire project for you. Come back when you have some code that's not working, or when you have a specific design question. – Jonathan Hall Jun 27 '19 at 08:22
  • haha @Flimzy, I get your point, been searching and reading about how to go about that. however I need a quick direction as I am facing a deadline. some direction would help – Neo Jun 27 '19 at 08:29
  • 4
    "Quick direction" for such an ambitious project isn't really possible. Who imposed your deadline? Is this homework? If so, your professor should provide that guidance. Is it a work assignment? Talk to your boss about expectations. – Jonathan Hall Jun 27 '19 at 09:31
  • 1
    You want to build a copy of the Go Playground https://github.com/golang/playground – georgeok Jun 27 '19 at 13:27

1 Answers1

3

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.

TehSphinX
  • 6,536
  • 1
  • 24
  • 34