Go is an incredibly useful programming language, but not all that popular among web developers. Most other languages that are used for web development have dominant frameworks - Ruby has Rails, PHP has Laravel, Python has Django, and so on. Golang web frameworks for web development are a bit more fractured with several competing (and in some cases complementary) options. In this article, we'll explore a few of the most popular Go web frameworks so that you can make a decision on which to use with confidence.

Choosing Gin is a pragmatic option

Gin is the most widely used web framework for Go at this point. It strikes an excellent balance between speed, ease of use, and feature set. One of it's greatest selling points is speed. It's built on top of httprouter, which the Gin team credits with making it up to forty times faster than the older web framework Martini.

The Go Gin web framework homepage

Gin also has built-in middleware, making it easy to do logging and support other common web app requirements. Gin's API is relatively simple, making it easy to become productive.

Starting a web project with Gin

Gin's README has an example of a fully functional Gin app to show off its simplicity. Take a look:


package main

import (

  "net/http"

  "github.com/gin-gonic/gin"

)

func main() {

  r := gin.Default()

  r.GET("/ping", func(c *gin.Context) {

    c.JSON(http.StatusOK, gin.H{

      "message": "pong",

    })

  })

  r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")

}

You can test this app by visiting localhost:8000/ping and confirming that you see "pong".

When to choose Gin

Gin is a great choice if you want to quickly get started with something simple and flexible. It's a very performant web framework and lets you take advantage of Go's speed without having to get into the details of httprouter or net/http. It's also a good choice if you'd benefit from a diverse ecosystem of community-supported middleware. (who wouldn't!)

When to avoid Gin

Unlike Rails or even Laravel, Gin is minimal and relatively unopinionated. If you need a strict structure or want the benefits of a strict MVC structure, it's probably not the right choice for you. It also doesn't have as many features as something opinionated like Rails, so it's not a great choice if you're uncomfortable building or importing things it doesn't provide.

Choosing Echo for scaling web apps

Echo’s performance is impressive and handles garbage collection efficiently. If speed is a concern on your project, Echo may be your best option. It's similar to Gin but has even more features built right in. It has authentication, including JWT support, right out of the box. People also love that it has flexible routing, including groups and support for custom middleware.

The Echo Go framework homepage

Writing a web server with Echo

You may find a few points in the Echo documentation listed as a "work in progress," but Echo’s maintainers have posted numerous recipes to get programmers going.


# Echo also looks kind of like Sinatra. I'm sensing a pattern. 

blog := echo.New()

blog.Use(mw.Logger())

blog.Use(mw.Recover())

hosts["blog.localhost:1323"] = blog

blog.Get("/", func(c *echo.Context) error {

   return c.String(http.StatusOK, "Blog")

})

When is Echo the right choice?

It makes sense to choose Echo if you need more built-in functionality than Gin but aren't willing to sacrifice too much flexibility. It's a great fit if you need WebSockets, JWT authentication, or session management. It's also a good option if you have some custom middleware in mind.

Echo might not be a good fit if you value simplicity. Gin remains the best option if simplicity is your primary decision-maker. It also might not be a good fit if you're looking for a strict structure similar to what Rails provides.

Choosing Fiber for performance

Fiber is another really great option among Golang frameworks. It's explicitly inspired by Express.js, claiming to make performant web apps with Go even easier. If you're coming from a JavaScript app, the framework's syntax is likely to feel familiar.

The Fiber Go web framework

It's written on top of Fasthttp, the fastest Go HTTP engine. This makes it crazy fast, even by Go's standards. It also includes support for features like WebSockets, session management, and rate limiting.

Starting a web project with Fiber

Writing Hello World in Fiber is just as simple as Gin:


package main  



import "github.com/gofiber/fiber/v2"  



func main() {  

app := fiber.New()  



app.Get("/", func(c *fiber.Ctx) error {  

return c.SendString("Hello, World!")  

})  



app.Listen(":3000")  

}

This starts a web server that listens to port 3000 and responds to the root route with "Hello, World!"

How do you know if Fiber is the right fit?

Fiber is great for a lot of reasons, so it makes the most sense to start with why you might not want to choose it.

If you want or need compliance with Go's standard library, Fiber isn't a viable option. It uses Fasthttp, and while that gives us incredible performance, the tradeoff is that it deviates from the standard library. Even if you just prefer sticking with net/http, Fiber deviates from that.

With that out of the way, Fiber is a good fit if you're building high-performance APIs, especially if you like the simplicity and syntax of Express.js.

Choosing Beego gives you lots of features

Looking for a framework that is performant and has strong conventions? Beego is worth trying out. The framework is designed for full-stack web development and comes with many things Rails developers take for granted. It comes with an ORM for making database queries, strong MVC conventions, built-in logging, and even a CLI. As an added bonus, the Bee tool auto-compiles, reloads, tests and deploys Beego applications efficiently.

The Go Beego web framework documentation

Beego has a huge amount of documentation and demos, though some are difficult to understand the first time through. You might have to set aside a little extra time for the documentation, but that investment will pay dividends.

Writing "Hello world!" with Beego

Beego's version of Hello World is probably the easiest of all the frameworks. Take a look at this example. First, you'll need to create and change into a new directory:


mkdir hello

cd hello

Then run:


go mod init

Finally, install the package:


go get github.com/beego/beego/v2@latest

Now, you can create a hello.go file with the following contents:


package main

import "github.com/beego/beego/v2/server/web"

func main() {

    web.Run()

}

Why might someone choose Beego?

Beego is relatively opinionated. It's a great framework if you want a fully-featured full-stack framework like Rails, Django, or Laravel. It ships with an ORM, and its strong conventions make it a great choice for large, enterprise projects.

That being said, Beego is a poor choice if you don't want to use MVC, you don't need an ORM, or you want a lightweight framework.

Choosing Buffalo for rapid iteration

Buffalo is a Go web framework focused on speed of development. Like Rails, Buffalo emphasizes convention over configuration. This means that rather than having to configure everything you need, the framework comes with strong defaults that fit many use cases and don't require intervention.

The Buffalo Golang frameworks homepage

This Go framework comes with generators, an entire frontend pipeline, and even task runners. It's great for developers who like fast feedback loops (who doesn't!).

What is starting a Buffalo project like?

After installing Buffalo, you can create a new project by running:


buffalo new <project-name>

After that, you can simply run the following:


buffalo dev

This will run your application server and watch relevant files for changes. If it detects changes, it will rebuild and restart your application binary for you.

When is Buffalo a good fit?

Buffalo is a good choice for building traditional full-stack web applications, but not ideal for just building APIs. If you want your framework to have a solid built-in asset pipeline, you'll probably be happy with Buffalo. On the other hand, if performance is your main concern, you will be happier with Fiber or even Gin. And lastly, minimalists will likely find the boilerplate and features of Buffalo to be a bit much.

Using Gorilla for modular libraries

Technically speaking, Gorilla is a web toolkit, rather than a web framework. However, packages within Gorilla will make your projects easier to launch. Gorilla Mux, for example, is an especially powerful URL router and dispatcher.

Go Gorilla libraries

Gorilla also has packages for saving sessions, authenticating, encrypting cookies, and websockets. In addition to the documentation on the Gorilla site, there's a strong community able to provide some support. You can also easily use Gorilla in conjunction with other frameworks.

Here's an example of a web server built with Gorilla's Mux:


# Mux isn't a web framework, but it has tools for routing, sessions

# and other things you need to make a web app. 

r := mux.NewRouter()

r.HandleFunc("/", HomeHandler)

r.HandleFunc("/products", ProductsHandler)

r.HandleFunc("/articles", ArticlesHandler)

http.Handle("/", r)

Why would someone build web apps with Gorilla?

If you want ultra-fine control over your application, using Gorilla helps you with that! Building with Gorilla empowers you to compose your application modularly, rather than having to ship something with lots of code you don't need. On the flip side, Gorilla isn't a great choice if you want a batteries-included framework with strong conventions.

Which of the Golang frameworks is best for you?

Choosing the right Golang framework depends on what you need from your application. If you’re looking for a fast, flexible, and easy-to-learn framework, Gin is the obvious choice. It’s lightweight, performant, and has a large ecosystem, making it a solid default for most Go web projects. That being said, Gin is fairly minimal.

If you need more built-in functionality, Echo provides similar performance but with additional features like authentication and WebSockets, making it a better choice for larger applications with more complex needs.

If performance is your top concern, Fiber is worth considering. It’s built on fasthttp, making it one of the fastest Go frameworks available. The Express-inspired API also makes it particularly appealing to developers coming from a JavaScript background.

For developers who prefer a full-featured, opinionated framework, Beego and Buffalo offer more structure. Beego follows an MVC pattern and includes an ORM, caching, and a built-in CLI. It's a great choice for enterprise applications where convention and consistency matter.

Buffalo, on the other hand, is more focused on developer experience, with generators, an asset pipeline, and hot reloading, making it a great choice for rapidly building traditional web applications. The tradeoff is that these frameworks are simply much heavier than Gin, Echo, or Fiber, which may not be desirable if you’re optimizing for simplicity.

Rather than a full-fledged framework, Gorilla provides modular libraries for routing, sessions, authentication, and WebSockets. If you prefer Go’s standard net/http package but want some extra functionality, Gorilla is a great fit.

Ultimately, the best of the Golang frameworks depends on your priorities. Whichever you choose, Go’s web ecosystem has matured to the point where you can build scalable, maintainable web applications with confidence and without building everything from scratch!

Get the Honeybadger newsletter

Each month we share news, best practices, and stories from the DevOps & monitoring community—exclusively for developers like you.
    author photo
    Jeffery Morhous

    Jeff is a Software Engineer working in healthcare technology using Ruby on Rails, React, and plenty more tools. He loves making things that make life more interesting and learning as much he can on the way. In his spare time, he loves to play guitar, hike, and tinker with cars.

    More articles by Jeffery Morhous
    An advertisement for Honeybadger that reads 'Move fast and fix things.'

    "We love Honeybadger. Not only is it a fab tool and very affordable, they feel like a partner - whenever we needed help we got FIRST CLASS service."

    Fix errors, eliminate performance bottlenecks, and dig into the details faster than ever before. With support for Ruby, Elixir, and 8 other languages, Honeybadger is the best way to gain real-time insights into your application’s health and performance.

    Get started for free
    Simple 5-minute setup — No credit card required