6 🔥 Awesome Golang packages (web devs)
Tags: programming, opensource, webdev, go
Published: 2023-12-04 20:04:51

Golang's standard library is just pure awesomeness for sure, it's packed with most of what you need and minimal by design. 

Sometimes though, when you feel extra lazy 😜 it's nice to pull down a GitHub library or two to make life a little easier.

## 1) Air

When building web apps with Golang, it's a pain to keep exiting and rebuilding your project's binary every time you make a change.

"Air" is a neat package that detects file system changes in your project and automatically updates the compiled binary - giving you a similar experience to JavaScript tools like Vite or Webpack.

GitHub repo: [https://github.com/cosmtrek/air](https://github.com/cosmtrek/air)


## 2) Gabs

Working with JSON in Golang can sometimes be painful when the API or source of the JSON is not very reliable or changes often. Sure you can use structs to model your JSON, and you should for most cases, however sometimes to keep your sanity intact - you can just use "Gabs".

GitHub repo: [https://github.com/Jeffail/gabs](https://github.com/Jeffail/gabs)

Here's an example:
```golang

gabs.ParseJSON([]byte{`json text here`})
fmt.Println(jsonParsed.Path("user.first_name").String())
```

## 3) GORM

It's easy and clean to work with the standard SQL package in Go, however, if you come from Python or PHP - you are spoiled for choice with ORM's.

Golang may not have that many options, but GORM is certainly one of the most intuitive ORMs I have ever used. No unnecessary abstraction and you can even use RAW SQL whenever needed. Works seamlessly with structs as well.

Homepage: [https://gorm.io/](https://gorm.io/)

## 4) Templating with Pongo2

The default templating package in Golang's standard lib is fine, but I always felt it a bit weird compared to modern templating engines like Blade or Jinja.

Luckily, there is a good package available similar to Django templates called "Pongo2".

GitHub repo: [https://github.com/flosch/pongo2](https://github.com/flosch/pongo2)

> If you prefer Jinja templates, there's a fork of pongo2 here: [Goja](https://github.com/noirbizarre/gonja), doesn't seem actively maintained but I used it recently and it works pretty well.

## 5) Two-factor authentication

Adding 2-factor auth can be a tedious process if you going to set this up from scratch, however, I found a cool package that does the heavy lifting for you, and implementing this into a web project is fairly trivial.

GitHub repo: [https://github.com/pquerna/otp](https://github.com/pquerna/otp)

## 6) GIN framework

This is already pretty well known in the Golang community, but just in case you didn't know - GIN is one of the best Golang frameworks because It's fast, minimal, and has a very clean and declarative router.

Don't expect a Laravel or Django replacement, however, coupled with some of the packages mentioned above - it's a powerful web framework that you can build just about anything with.

GitHub repo: https://github.com/gin-gonic/gin

> The only annoying issue with GIN is that CSRF protection doesn't come baked in by default. Otherwise, it's a fairly good framework to use.

## Conclusion

Golang's core philosophy is to keep things as minimal as possible and use the standard library wherever possible, however, it's nice to see the ecosystem around Golang rapidly growing and maturing over time. 

It's an amazing language with a great open-source community.