Cookies management by TermsFeed Cookie Consent
Russia has invaded Ukraine and already killed tens of thousands of civilians, with many more raped or tortured. It's a genocide. We need your help. Let's fight back against the Russian regime.
Help Ukraine! Fight the Russian regime!

Init project structure

Please consider supporting us by disabling your ad blocker


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:

├── app
├── cmd
├── go.mod
└── website


  • 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.