Let's Go Advanced routing › Choosing a router
Previous · Contents · Next
Chapter 7.1.

Choosing a router

There a literally hundreds of third-party routers for Go to pick from. And (fortunately or unfortunately, depending on your perspective) they all work a bit differently. They have different APIs, different logic for matching routes, and different behavioral quirks.

Out of all the third-party routers I’ve tried there are three that I recommend as a starting point: julienschmidt/httprouter, go-chi/chi and gorilla/mux. They all have good documentation, decent test coverage, and work well with the standard patterns for handlers and middleware that we’ve used in this book.

All three routers also support method-based routing and clean URLs, but beyond that they have slightly different behaviors and features. You should pick between them depending on the specific requirements that your project has.

In summary:

In our case, our application is fairly small and we don’t need support for anything beyond basic method-based routing and clean URLs. So, for the sake of performance and correctness, we’ll opt to use julienschmidt/httprouter in this project.