It might be easiest to download a Golang Docker image and use that for development:
docker pull golang:1.10
You can find other available tags on the docker hub page
Set HOME
so we can use the local cache in ~/.cache/go-build
chex -i golang:1.10 -a "-e HOME=/opt/shared/${USER}" bash
We need the mux library to route requests
go get github.com/gorilla/mux
make all
make run
Use curl
to send start
and stop
commands to the go
server process
$ curl -v -s -X POST -H "Content-Type: application/json" -d '{"start":"8"}' localhost:4723/start
* Trying ::1...
* Connected to localhost (::1) port 4723 (#0)
> POST /start HTTP/1.1
> Host: localhost:4723
> User-Agent: curl/7.47.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 13
>
* upload completely sent off: 13 out of 13 bytes
< HTTP/1.1 201 Created
< Content-Type: application/json
< Date: Fri, 20 Jul 2018 04:18:43 GMT
< Content-Length: 11
<
* Connection #0 to host localhost left intact
{"pid":645}
$
$
$
$ curl -v -s -X GET localhost:4723/stop
* Trying ::1...
* Connected to localhost (::1) port 4723 (#0)
> GET /stop HTTP/1.1
> Host: localhost:4723
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Fri, 20 Jul 2018 04:19:10 GMT
< Content-Length: 17
<
* Connection #0 to host localhost left intact
{"status":"done"}