20 Go Packages You Can Use in Your Next Project

Improve your application and save your time.

Fernando Souza
Dec 10, 2020 · 6 min read
Image for post
Image for post
Photo by Todd Quackenbush on Unsplash

Go is an amazing language that you can use to build almost any kind of program. Developed in 2007, it has the ease of an interpreted language while also being fast and efficient as a compiled language. It was also built thinking about concurrency and getting advantage of the multicore machines. You can even write programs to embedded devices.

Since then, a lot of nice programs and tools have been created using Go, such as Kubernetes, Consul, and NSQ.

With only the standard packages from Go you already can build a nice application.

Fortunately, Go has a vibrant community that creates and shares a lot of libraries that you can use to improve your development. Let’s see some of them in this article.

Golang-Set

An attempt to mimic the primary features of the set data structure from Python into Go. An example of the use:

You can know more about it here.

Go kit

It is a toolkit to implement microservices. It handles the basic about a distributed system, so you can focus on your business logic.

If you want to adopt a microservice architecture in your solution, “Go kit will help you structure and build out your services, avoid common pitfalls, and write code that grows with grace”.

Check out here.

GRequests

It is a Go “clone” of the famous Python requests library. You can easily do a HTTP request, upload/download a file, or serialize a response into JSON or XML.

If you have worked with Python, you will feel very comfortable using it.

Ws

The package ws implements a client and server for the WebSocket protocol. It has some nice features, such as zero-copy upgrade and low-level API in case you want to write your own logic.

You can know more about it here.

Email

A robust and flexible email library. It provides a more human interface to send emails using Go.

You can add attachments, send text / html messages, or add custom headers, in a very clear way.

You can know more about it here.

Gin

With more than 44k stars on Github, it is one of the most popular Go library. It is a web framework, and it focus on productivity and performance.

It has a lot of features, such as middleware customization, serving static files, handle multiple data formats, and HTML rendering.

If you want to develop an API or a Web application, you should definitely consider using Gin.

Fuzzy

Go library that provides a fuzzy string matching in the same style as Sublime, VSCode, etc.

It only depends on the Go standard library, and it is fast. It is a good choice if you want to add a search functionality to your application.

Github here.

Image for post
Image for post

Authboss

Authentication is a mandatory part of any modern web application. Creating all the necessary boilerplate can be cumbersome, and you can actually miss something.

This library aims to help you implement an authentication system, saving you time and avoid some mistakes that you might do.

Check the documentation here.

Uuid

This package provides a pure Go implementation of UUID, supporting both creation and parsing.

It supports from version 1 to 5, and it is simple to use.

More information here.

Gorm

If you are implement an API, there are good chances you will need to connect to a database. While you can do this by hand, using a ORM can save you a lot of time.

Gorm is a fantastic ORM library for Go. You can create models, associations, hooks, transactions, and a lot more nice features.

It is also a mandatory library if you want to work with a database.

Graphql

If you want to add support to GraphQL, then this is your package. It supports queries, mutations, and subscriptions.

Check the Github here.

Image for post
Image for post
Source here.

Ginkgo

One of the biggest complains of the community is the poor native Go testing packages.

Ginkgo extends standard testing package, allowing expressive BDD (Behavior-Driven Development) style tests.

Check the documentation here.

Errors

Outstanding library for error handling. The main feature is to handle the error identical to the official way, but with the addition of an annotation without losing the original error context (files and line numbers).

As stated in the documentation, the error handling becomes:

if err := SomeFunc(); err != nil {
return errors.Annotate(err, "more context")
}

This can save a lot of time during your development or even when trying to find that annoying bug.

Image for post
Image for post
Source here.

Cobra

It is both a library to create CLI programs as well as a program to help you create a well-structure application.

It has great features as nested commands, flags, intelligent suggestions, help generation, and more.

If you need to create a CLI program, cobra is the only tool you need.

Logrus

Another popular library for Go, Logrus is a structured logger that provides a comprehensive extension for the native logging package.

You can also add some hooks to be executed when a certain error level occurred.

Check the documentation to see how to use it.

Dateparse

With this library you can parse date strings without knowing the format. It reads the bytes and uses a state machine to find the correct format.

t, err := dateparse.ParseAny("3/1/2014")

Check the documentation for more examples.

Gonum

A set of numeric libraries for Go. It contains libraries for matrices, statistics, integration, differentiation, among others.

If you need to include some mathematics in your code, you have to use it. It saves you time and gives you a consistent scientific code.

Check the documentation for how to use.

Gopsutil

Another library that was inspired by a Python package. You can retrieve information about running process and system utilization on different platforms.

It is useful to monitor your system resources and processes.

Check the documentation here.

Image for post
Image for post
Source here.

Fyne

You can create a beautiful GUI application for desktop and mobile using the nice Fyne package.

It is based on Material Design, so it has nice features of usability, widgets, layouts, and it is designed to be easy to develop.

Check out the documentation.

Ants

A nice feature of the Go language is the concurrency support and the goroutines. But managing all the routines in an application can be really challenging.

The ants library implements a pool that manage and recycle a massive number of goroutines, automatically. It has nonblocking mechanisms and handle panic without crashing an application.

If you need to create an application that uses concurrency, you should definitely check this library out.

Conclusion

Go is a fantastic language, with nice features from the standard library. But even with support, sometimes you need an extra help.

The community has already built a lot of great libraries that can help you, either by saving your time, so you don’t need to implement again, or by creating an easy to use interface.

If you know another awesome library that is not listed here, leave a comment.

Vacatronics

Electronic, robotics, programming, IoT, and other cool stuffs.

Sign up for Vacatronics

By Vacatronics

A publication about electronics, programming, maker projects, IoT, and other fun stuffs. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Fernando Souza

Written by

Enthusiast of programming, electronics, technology and beer, not necessarily in that order. BuyMeACoffee: buymeacoffee.com/ustropo

Vacatronics

Electronic, robotics, programming, IoT, and other cool stuffs.

Fernando Souza

Written by

Enthusiast of programming, electronics, technology and beer, not necessarily in that order. BuyMeACoffee: buymeacoffee.com/ustropo

Vacatronics

Electronic, robotics, programming, IoT, and other cool stuffs.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app