Cookies management by TermsFeed Cookie Consent

Init project structure

Please consider supporting us by disabling your ad blocker

6/21

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 the Website 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 the cmd directory.
  • cmd is a directory that will contain three apps running our repository demo procedure, one for each repository implementation: with the classic database/sql approach, with the pgx database client, and with the GORM ORM.
6/21