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