This is a template project which can\should be used as a blueprint for new projects
The application depends on config values that are located in the environment variables. It means that before execution of any CLI command, the corresponding env. variables should be defined.
In Linux and macOS you can define and set a value of an env. variable by the export command
Example. Let's set the value of the DB_MIGRATIONS_PATH env. variable
export DB_MIGRATIONS_PATH=/Users/levboiko/go_projects/boostylabs/project_template/database/migrations
Another handy way for setting of env. variables, is to "import" a corresponding .env file export $(grep -v '^#' [.env file location] | xargs)
Example:
export $(grep -v '^#' ./.env | xargs)
Sample of configuration is in .env.dist file
The CLI command to launch the application
export $(grep -v '^#' ./.env | xargs)
go run cmd/template_project/main.go rungo run cmd/database/main.go create-migration [migration_name]
Example:
export $(grep -v '^#' ./.env | xargs)
go run cmd/database/main.go create-migration initSample output:
new file: 000001_init.up.sql
new file: 000001_init.down.sql
go run cmd/database/main.go migrate up
Example:
export $(grep -v '^#' ./.env | xargs)
go run cmd/database/main.go migrate upIn case of successful execution, there will be an empty output
go run cmd/database/main.go migrate down
Example:
export $(grep -v '^#' ./.env | xargs)
go run cmd/database/main.go migrate downIn case of successful execution, there will be an empty output
- Create a
.envand set all params - Run the
docker-composecommand as it shown below
docker-compose --env-file=.env upor
docker-compose --env-file=.env up -d- Apply migrations
export $(grep -v '^#' ./.env | xargs)
go run cmd/database/main.go migrate up- Lunch a required application
export $(grep -v '^#' ./.env | xargs)
go run cmd/template_project/main.go run- Visit the
http://localhost:3030/url to open Grafana UI- Credentials are admin\admin
- Pick a dashboard Go Metrics
In order to run test we need "import" env. variables and run go test CLI command
For example, let's run tests for the 'dummy' package
export $(grep -v '^#' ./.env | xargs)
go test ./dummy