Init project structure
So let’s start creating our project. Open Terminal and create a new directory named postgresql-intro
in a location of your choice.
mkdir postgresql-intro
Go to the directory:
cd postgresql-intro
and create a new Go module for our project:
go mod init postgresql-intro
Then create three new directories in the postgresql-intro
project:
mkdir cmd
mkdir website
mkdir app
The initial project tree should look like this:
postgresql-intro
├── app
├── cmd
├── go.mod
└── website
where:
go.mod
is the Go module definition.website
is our domain package. We are going to create a mini ranking of websites, so we will put theWebsite
domain object, the repository definition, and its three implementations here.app
is the package that will contain the demo procedure of our repository and that will be used by all apps in thecmd
directory.cmd
is a directory that will contain three apps running our repository demo procedure, one for each repository implementation: with the classicdatabase/sql
approach, with thepgx
database client, and with the GORM ORM.