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?
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.