Creating database models

Let us write a few SQL strings for creating the tables for the preceding train, station, and route resources. We are going to create a project layout for this API. The project layout will look like the following screenshot:

                           

We create our projects in $GOPATH/src/github.com/user/. Here, the user is narenaryanrailAPI is our project source, and dbutils is our own package for handling database initialization utility functions. Let us start with the dbutils/models.go file. I will add three models each for train, station, and schedule in the  models.go file:

package dbutilsconst train = ` CREATE ...

Get Building RESTful Web services with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.