July 2019
Intermediate to advanced
502 pages
14h
English
Before diving into the code, let's consider what we want to accomplish. We want a local empty database to be created. We want to launch it as a Docker container, but only if it's not running already. In order to do that, we need to check whether a Docker container is running already, if we should restart it, or if we should run a new one. Then, we will try to connect to the target database and create it if it doesn't exist. The service will be responsible for creating the schema if needed because the generic DB utilities know nothing about the database schema of specific services.
The db_util.go file in the db_util package contains all the helpers functions. First, let's review the imports that include the ...