1. 18
    1. 7

      From 2021 and perhaps not relevant as mux is eol?


      1. 2

        yeah, I’ve been wondering about that. gorilla was so popular for so long, and now it’s eol. I know I’ve used it in professional projects. I guess everyone saying to just use the standard library were proved right in this scenario. Not that it’s a huge deal though, the code still works.

      2. 1

        Fair enough, but I posted this because another article about Go routing was on the front page—and it was from 2020.

    2. 6

      Article author took best of both approach and wrote Flow: https://www.alexedwards.net/blog/introducing-flow

      1. 3

        There’s a pretty large collection of routers in go, probably in no small part because of how easy it is to do with the standard library; Flow is ~160 lines of code. Carlmjohnson who posted original last year ended up writing their own router as well.

        To add another to the list Labstack’s Echo is probably my personal favorite.

        1. 1

          That’s the biggest problem with Go. Things are so “easy” that everybody writes stuff themselves and then they end up with a pile of code (for better or worse).

    3. 3

      IMHO this article (and the flow chart) is flawed, since there is no “do not use a router” option. Many (even more complex) use cases do not need a router. Adding a dependency is almost always worse than adding a few lines of manual code to do something simple yourself. A router is just a helper that facilitates “if-then-else” flow. If you have a tiny web server, don’t use a router. That’s just my opinion though.

      1. 4

        There’s a large chunk near the beginning of the article which starts with “I’ll start by saying that if you can use http.ServeMux, you probably should.” and goes on to say “In fact, the only time I’d recommend not using [http.ServeMux] is when you need support for variables in URL paths or custom routing rules.”

    4. 2

      I have used a few of those mentioned in the article, the one I have settled with is chi. It uses the standard library and the code is “easy” to read and follow. I use it in all my API projects.

    5. 2

      I really enjoy using go-chi. It’s straight forward but has options for complex use cases. It uses the handler from the standard library so it integrates well with everything. It also comes with middleware, which is easy enough to use, or to crib of off to write your own.

    6. 2

      At my company our recommended router is chi for new projects, where we were using gorilla/mux previously

Stories with similar links:

  1. Which Go router should I use? via carlmjohnson 1 year ago | 36 points | 8 comments