Help Creating Go Sandbox To Execute Untrusted Golang Code

Hello,

I am interested in a Go sandbox to execute arbitrary, untrusted Go code delivered via curl.

I believe the most well-known sandbox like this is https://play.golang.org/

I found the github repo where this code lives (https://github.com/golang/playground) and I am trying to run the example they provide in the repo.

The README from the Github seems to suggest I can execute arbitrary code via a Docker image + curl.

Here is the example from the README below.

docker build -t golang/playground .
docker run -d --name=play --rm -p 8080:8080 golang/playground
# run some Go code
cat /path/to/hello_world.go | go run client.go | curl -s --upload-file - localhost:8080/compile

While this seems straightforward, it isn’t working.

Issue seems to be a “SANDBOX_BACKEND_URL” environment variable.

ERROR MESSAGE:

#Golang Error
cmdFunc error: POST "http://sandbox_dev.sandnet/run": Post "http://sandbox_dev.sandnet/run": dial     tcp: lookup sandbox_dev.sandnet on 127.0.0.11:53: no such host

#http/mux Error
2020/10/17 20:39:26 http: panic serving 172.17.0.1:60486:
no SANDBOX_BACKEND_URL environment and no default defined for project ""

Can anyone can help me understand the error and help me execute the code from the example?

1 Like

What I’ve Tried So Far:

There is a Makefile in the Github repo that has some steps for running the Dockerized environment.

The relative contents of the Makefile are:

runlocal:
    docker network create sandnet || true
    docker kill play_dev || true
    docker run --name=play_dev --rm --network=sandnet -ti -p 127.0.0.1:8081:8080/tcp golang/
    playground --backend-url="http://sandbox_dev.sandnet/run"

When I create the Docker network and run the container with the --backend-url set it runs into the same problem.