perScoreCal
Getting Started
Dependencies
-
Go Lang - installed and Go path set
-
PostgreSQL - installed and running
-
Clone this project to $GOPATH/src
-
A .env file in the root of the project with the following keys
export DEV_DB_DRIVER=
export DEV_HOST=
export DEV_DBNAME=
export DEV_SSLMODE=
export DEV_USERNAME=
export DEV_PASSWORD=
export TEST_DB_DRIVER=
export TEST_HOST=
export TEST_DBNAME=
export TEST_SSLMODE=
export TEST_USERNAME=
export TEST_PASSWORD=
-
From the root of the project execute source .env
-
Install the godep
package with go get github.com/tools/godep
-
Install package dependencies with godep restore
Build and run this project
-
Give privilege to the setupPostgres.sh file
chmod +x setupPostgres.sh
-
Execute setupPostgres.sh to create Postgres role and database
./setupPostgres.sh
-
Run command to migrate database
go run main.go setupdb
-
Start the server
go run main.go serve
Code structure and details
Directory structure
perScoreCal
- .git
- cmd
- Godeps
- models
- perScoreProto
- server
- vendor
-- main.go
-- setupPostgres.sh
Description
The cmd
directory holds the code for the CLI commands created by Cobra. The project itself was created using the Cobra Generator.
The Godeps
directory contains the Godeps.json
file which is where all the package dependencies for the project is saved.
The models
directory holds all the business logic and data operations using the Gorm
package.
The perScoreProto
directory holds the Proto definition files as well the compiled Go files generated by the protoc
command.
The server
directory has two files - one for bringing up the GRPC server and another to route the requests to methods/functions.
The main.go
file is what we use to fire the commands, including bringing up the server. It is the entry point to the application.