GoLang Useful Packages For Projects

Created At: 2023-04-30 18:17:07 Updated At: 2023-04-30 19:22:39

Let's learn about the most important packages for GoLang projects. I have used them in a project where I have used GoLang and Postgres for rest api.

Sqlx

github.com/jmoiron/sqlx

sqlx is a package for Go which provides a set of extensions on top of the excellent built-in database/sql package. From this package you can get sqlx.Connect(), which is very important for database connection. You also get DB object, which helps you to maintain database connection pool.

PQ driver

github.com/lib/pq

It is a is a popular third-party package for the Go programming language that provides a pure Go driver for the PostgreSQL database. It allows Go programs to connect to and interact with PostgreSQL databases by providing a simple and efficient API for executing SQL queries, retrieving results, and managing transactions

Postgres and migrates packages

github.com/golang-migrate/migrate/v4
github.com/golang-migrate/migrate/v4/database/postgres

The first one is for migrating the database and second one is the actual postgres package.

From the first package you can use the function migrate.NewWithDatabaseInstance().

From the second package we can use the function postgres.WithInstance() and it returns a database driver.

Comment

Add Reviews

Recommended Posts

Latest Posts

Subscribe our newsletter