A simple Go / MySQL and REST API starter project

You should have a MySQL instance running locally with a songs database prepared per the scripts/ script.

Install the Go MySQL driver

    go get

    go clean 
    go build

Then in another terminal access the endpoint:
    $ curl -i http://localhost:8080/songs/4 ; echo
    HTTP/1.1 200 OK
    Content-Type: application/json
    Date: Wed, 16 Jul 2014 14:26:08 GMT
    Content-Length: 80
    {"id":4,"name":"Sunday Mornin' Comin' Down","date-written":"1969-01-01 00:00:00"}
Unit testing

    $ go test -coverprofile=coverage.out
    $ go tool cover -html=coverage.out -o coverage.html
    $ open coverage.html

Imports 1 package(s) ΒΆ