6 must-have web frameworks for the Google Go language

Discover the most popular, powerful, and versatile frameworks for building sites and REST APIs in Go

The Google Go language (aka Golang) has become a strong choice for writing web services and APIs. It compiles to fast-running native code, it has native metaphors for asynchronous programming and other features useful for web services, and it has a broad and expanding audience of users.

Here’s a survey of the major frameworks currently used for web development in Go. Some are aimed at simpler use cases, like endpoint APIs. Others are intended to handle full-blown site development, or can be scaled up or down depending on which components you need for a given job.

Go web framework: Beego

Beego is reminiscent of the all-inclusive Django web framework for Python in some respects. It comes with a wide range of features common to web applications, organized into eight modules that can be used or ignored as needed. Aside from the usual model-view-controller (MVC) components found in most web frameworks, it also includes an object-relationship map (ORM) for data access, a built-in cache handler, session handling tools, logging mechanisms, and libraries for common operations with HTTP objects.

Another way Beego resembles Django is in its command-line tools. For example, you can use the bee commandto create Beego apps from scratch or manage existing ones.

Go web framework: Gin

One of the first web frameworks for Go was Martini, but that project is no longer maintained. However, in its wake, other Go frameworks have sprung up that use Martini’s basic metaphors but claim better performance and more features.

Gin is one such project. It uses a customized version of the httprouter package for speed, and it provides handlers for many common use cases: middleware, file uploading, logging, binding front-end HTML components to back-end data structures, and much more. The API is stable at Version 1.x, so future changes should not break existing Gin apps.

Go web framework: Gorilla

Gorilla is positioned as a “web toolkit,” not an MVC-style framework. It’s composed of libraries used to address various low-level aspects of writing a web service: context (for stashing state during the lifetime of a request), mux (route/dispatch), and other libraries for implementing secure cookies, sessions, websockets, and RPC over HTTP.

Templates, forms, and other front-end pieces aren’t part of the package. You supply those if you want them, whether through other frameworks that you use pieces of Gorilla in or through standalone components you integrate with something built with Gorilla.

Go web framework: Echo

Echo is another small framework, chiefly intended for APIs. It doesn’t include a templating system, for example; for that, you use Go’s own html/template and plug it in as needed. However, Echo does provide several useful middleware modules commonly used in APIs, such as basic and key-based authentication, compression, proxying, and logging.

Echo also comes with a slew of useful recipes, many of which don’t involve a lot of work to implement. If you manage HTTPS certificates with Let’s Encrypt, for example, you can set up a recipe to automatically install those certificates.

Go web framework: Iris

Iris comes billed by its creators as “a real Express.js equivalent for Go”—that is, a version of the JavaScript/Node.js web framework that uses a minimal design with most of its functionality provided by plugins. Iris includes basic MVC functionality, along with built-in support for middleware, sessions, routing, and caching.

The documentation is full of examples, including projects that interact with React front ends or run in a Docker/Kubernetes environment.

Go web framework: Revel

Ruby on Rails provided the world with a common pattern for an MVC-style web framework—so much so that other languages went and implemented frameworks of their own in its image. Revel has been billed by its own creators as being in the spirit of Rails.

Aside from providing basic MVC, Revel lets you plug in other components freely to satisfy other needs. Templating can come from Go’s own native html/template package, or one you provide. Likewise, the HTTP engine can be Go’s own or a third-party addition. Caching can be done natively in-memory, or through a Memcached or Redis back end. However, there’s no native ORM for databases. One example in Revel’s documentation uses the Gorp library, but in theory any Go ORM can be put to use.

Copyright © 2018 IDG Communications, Inc.