loading...
X-Team

6 Useful Go Frameworks in 2019

tdmoor profile image Thomas De Moor Originally published at x-team.com ・3 min read

The world needs more Go developers. The 2019 Stack Overflow Developer Survey showed that Go is the third-most-wanted programming language, after Python and JavaScript. That's why it shouldn't come as a surprise that Go developers are compensated highly. They have the second-highest salary globally ($80K) and the third-highest salary in the US ($136K).

Although Go is a relatively simple programming language, particularly when compared to its syntactically similar counterpart C, many complex open-source projects run on Go, from Docker to Terraform to Kubernetes.

Because of the increased need for Go developers and its popularity in big, open-source projects, developers have been wanting to extend the functionality of Go by building a good number of frameworks and libraries for it.

While the stdlib of Go is capable enough to create a production-ready microservice, and while many developers are in favor of using Go without any external libraries or frameworks, your project might require functionality that isn't baked into stdlib.

As such, here are 6 well-liked frameworks, as ranked by GitHub stars, that extend the functionality of Go.

labstack/echo

Echo is a minimalist web framework that serves as an excellent compromise between stdlib + router and a full-stack web framework. It comes with extensible middleware, central HTTP error handling, and template rendering for any template engine.

Many developers seem to prefer Echo over Gin, the Go framework that currently has most GitHub stars (28K), because Echo has better documentation, a better router pattern matching, and a nicer HandlerFunc signature than Gin.

go-kit/kit

Go Kit is the most popular toolkit for building microservices in Go. It aims to fill in the stdlib gaps for RPC safety, system observability, infrastructure integration, and program design.

Go Kit is lightly opinionated and designed for interoperability, so you can easily adapt it to your particular situation.

tsenart/vegeta

Vegeta is an HTTP load testing tool and the number one library to use for Dragon Ball Z fans. In particular, it tests HTTP services with a constant request rate. Use it to find possible bottlenecks in your architecture.

gorilla/mux

The Gorilla mux package is a URL router and dispatcher. It's not the most lightweight mux, but it's the most feature-rich one. It can match requests based on URL host, path, path prefix, schemes, header and query values, HTTP methods, and even on regex.

stretchr/testify

The Go stdlib doesn't have assertions, because its developers believe that developers use them as a crutch to avoid thinking about proper error handling and reporting.

But you might think otherwise. That's where Testify comes in: it's a set of packages that allow you to write tests so your code behaves as intended. It includes easy assertions, mocking capabilities, and testing suite interfaces and functions.

jmoiron/sqlx

Go has a great database/sql library, but it's not perfect. Querying, for example, is a manual process. SQLx is a library where you can marshal rows into structs (with embedded struct support), maps, and slices. It also has named parameter support, including prepared statements, and it helps Get and Select to go quickly from query to struct/slice.

However, SQLx is not an ORM, so you'll still spend some time writing repetitive code. If you want to use an ORM, you can use GORM. However, keep in mind that it's significantly slower than SQLx when it comes to querying.


There you go: six frameworks and libraries that extend the functionality of Go. If you want to explore other Go frameworks, you can find a whole list at avelino/awesome-go. What about you? Which Go frameworks and libraries do you use?

Posted on by:

X-Team

X-Team is a 100% remote international company, originally founded in Melbourne, Australia. We help companies scale their development teams by providing them with extraordinary teams of developers from around the world.

Discussion

pic
Editor guide
 

Nice article, as the author of Iris and one of the most active github go developers I have to point out a small detail about the below conclusion of yours:

"As such, here are 6 well-liked frameworks, as ranked by GitHub stars, that extend the functionality of Go."

The most popular web frameworks, ranked by stars, are:

  • gin(32.7k stars) a very nice and light framework which has a big community around although it has a big amount of opened issues
  • beego(22.4k stars) one of the oldest web frameworks written in Go
  • iris(16.6k stars) the newest framework of the list. Objectively it's the most featured web framework provides unique routing(which is compatible with net/http third-party packages as well) and macro functions(!) based on muxie project which is by far the fastest router, even faster than httprouter and echo's router, fully featured sessions and websocket packages with native scaling capabilities, view engine which does support 5 different template engines and of course its documentation is easy to read with more than 100 examples. Just 5 open issues and more than 80 users' feature requests approved
  • while echo has 15.5k stars and it's more like a router than a complete framework.
 

Have to say, I've been using echo a lot recently and I really enjoy it. There is just enough there for you to get stuff done. It's simple and lightweight.