Best API-only framework

Hi Gophers!

I’m a developer approaching Go as a 2018 goal. I have years of experience in Javascript and Ruby (Rails in particularly). So I’m here to ask you:

what is the best framework to build a REST API-only web project in Go?

Thank you!

Plain old net/http.

At least unless you need very fancy stuff for the routing. Back when I built something for university, I used some router though which automatically generated proper options routes. I will look up how this lib was called when I’m back at a computer and have access to those sources.

1 Like

I took a look and the router I used was, mainly because the project for the university had strict requirements that I was able to fullfil by simply setting some options in that router (redirect for trailing slash and a proper response to OPTIONS requests).

The simplest way is to start with standard HTTP library. You can add bonus components later depending on what you need. The common choices for lightweight mix-ins are gorilla/mux for routing and sqlx for simpler DB access.

On the other hand, you can use a more opinionated framework, like gin.

Also, you may want to check a good discussion of this topic on reddit.

What is this framework supposed to contain? Just the http part?

FYI I ended up using Gin. I’m loving it so far :slight_smile: any suggestions about Gin?

If you’re coming from Rails then you will feel at home wtih Go Buffalo.

buffalo new myapp --api

My favorite is chi.

1 Like

Like @acim told, take a look at chi, it almost the std lib with goodies included like router and middleware. I have used gin, echo and some others, chi, by far, was the best.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.