Connecting to a Database with Go

This post will give a basic Go main.go file that can connect to a database and perform the basic CRUD operations.
I have created a test PostgreSQL database to demonstrate this.

I have created a new main.go file and will initiate the go mod file with the below

Basic Steps

The basic skeleton of the programme will be as follows

Install PGX

Connect and Ping Database

Full Programme to; Create, READ, Update and Delete

Leave a Comment

Your email address will not be published. Required fields are marked *