01/16/24

Go Microservices Frameworks in 2024

Which framework suits your project best?

9 Min Read

Go keeps growing as a popular programming language and is now in 2024 a common choice for building cloud-native microservices applications. Go has even entered the Top 10 in the TIOBE programming languages index.

While Go historically does not have a strong culture of using frameworks, there are a few that have become established and these days developers should definitely consider them in order to boost productivity.

However, making the right choice can be challenging, so in this article we take a look at the leading frameworks and compare features, key use cases, and potential drawbacks.

Go Microservice Frameworks: An Overview

Here's a high-level overview of the different frameworks included in this article, the frameworks are compared based on the level of built-on support for various use cases and functionality.

EncoreGoMicroGo kitGin
Description:Backend SDKMicroservice FrameworkCollection of Go librariesWeb Framework
Use case:Event-driven and Distributed SystemsEvent-driven and Distributed SystemsDistributed systemsPerformant HTTP APIs
Transport protocols:HTTPHTTP, gRPCHTTP, gRPCHTTP
Low boilerplate:✅︎ Yes✅︎ Yes✅︎ Yes✅︎ Yes
Authentication:✅︎ Yes✅︎ Yes✅︎ Yes✅︎ Yes
Service discovery:✅︎ Yes✅︎ Yes✅︎ Yes❌ No
Async messaging:✅︎ Yes✅︎ Yes❌ No❌ No
Built-in API Docs:✅︎ Yes✅︎ Yes❌ No❌ No
Automatic Local Dev Infra:✅︎ Yes❌ No❌ No❌ No
Built-in Tracing:✅︎ Yes❌ No❌ No❌ No
Built-in Architecture Diagrams:✅︎ Yes❌ No❌ No❌ No
Built-in Secrets Management:✅︎ Yes❌ No❌ No❌ No
Built-in Preview Environments:✅︎ Yes❌ No❌ No❌ No
Built-in Cloud Infra Automation:✅︎ Yes❌ No❌ No❌ No
Built-in Cloud Cost Analytics:✅︎ Yes❌ No❌ No❌ No

Encore

Encore Interface

Encore is a modern alternative for building Go microservices, purposefully designed to make it less complex to build event-driven and distributed systems. Encore solves for both the local dev experience and assists with deployment using robust and scalable services from AWS and GCP. It works by providing a Backend SDK that lets you declare infrastructure semantics as part of the application code.

Code Examples

Defining a service

With Encore you define a service by defining an API within a regular Go package. Encore recognizes this as a service, and uses the package name as the service name. When deploying, Encore will automatically provision the required infrastructure for each service.

On disk it might look like this:

/my-app ├── encore.app // ... and other top-level project files │ ├── hello // hello service (a Go package) │   ├── hello.go // hello service code │   └── hello_test.go // tests for hello service │ └── world // world service (a Go package) └── world.go // world service code

This means building a microservices architecture is as simple as creating multiple Go packages within your application. See the app structure documentation for more details.

Defining an API

To define an API, add the //encore:api annotation any regular Go function. This tells Encore that the function is an API endpoint. Encore will then automatically generate the necessary boilerplate at compile-time.

In the example below, we define the API endpoint Ping, in the hello service, which gets exposed as hello.Ping.

package hello // service name //encore:api public func Ping(ctx context.Context, params *PingParams) (*PingResponse, error) { msg := fmt.Sprintf("Hello, %s!", params.Name) return &PingResponse{Message: msg}, nil }

Defining a Pub/Sub topic

If you want a Pub/Sub Topic, you declare it directly in your application code, like so:

import "encore.dev/pubsub" type User struct { /* fields... */ } var Signup = pubsub.NewTopic[*User]("signup", pubsub.TopicConfig{ DeliveryGuarantee: pubsub.AtLeastOnce, }) // Publish messages by calling a method Signup.Publish(ctx, &User{...})

To run your application, you simply use encore run. Encore will automatically set up the local infrastructure and generate the boilerplate code necessary. You also get a local development dashboard with distributed tracing to help you understand and debug application behavior with ease.

Your code doesn't change when you want to deploy to the cloud. Encore will generate the necessary boilerplate and provision the necessary infrastructure in all environments:

  • NSQ for local development
  • GCP Pub/Sub for environments on GCP
  • SNS/SQS for environments on AWS

Key Features

  • No boilerplate: Declare APIs with an annotation on any function, create services from Go packages.
  • Built-in Distributed Tracing: Easily trace the path and performance of requests.
  • Automating API Documentation & Architecture Diagrams: Automatically keep documentation and diagrams up-to-date.
  • Built-in Secrets Management: Handle sensitive data securely.
  • Cloud Infrastructure Automation: Automatically provision infrastructure in local, preview, and your cloud environment in GCP and AWS.

Benefits

  • Scalability: Designed with large-scale applications in mind, Encore is an efficient way of building large distributed systems using battle-tested cloud services on AWS/GCP.
  • Simplicity and Speed: Encore abstracts away many of the complexities of infrastructure management, allowing developers to concentrate on coding.
  • Standardization: Provides a uniform way of building microservices and APIs, and provisioning infrastructure, that follows best practices.
  • Built-in Tools: Encore offers built-in distributed tracing, automated API documentation, preview environments, and more.
  • Cloud Agnostic: Encore applications can be deployed to any cloud provider, providing flexibility and preventing vendor lock-in.

Limitations

  • To get the most value from Encore you need to use the Backend SDK, which depending on your current situation may involve making changes to your current infrastructure management process.

Suitable for

  • For developers and teams looking for a batteries-included solution for building event-driven and distributed systems. Especially those that want to a high degree of automation for DevOps tasks and cloud infrastructure management.

When to consider Encore

  • When you want to build event-driven systems using scalable infrastructure like Pub/Sub.
  • When you want built-in observability like Distributed Tracing, Metrics, and integrations with tools like Grafana and Datadog.
  • When you want to automate API documentation and Architecture Diagrams, and remove most microservies boilerplate.
  • When you want a seamless integration between your code and infrastructure, with automatic cloud provisioning.

Try Encore

GoMicro (Orb)

Go Micro

GoMicro (to be renamed Orb) is a microservice framework that aims to simplify the challenges of building scalable and maintainable applications. GoMicro provides a pluggable architecture that allows developers to select and adapt the framework to fit their requirements, and integrates with various service discovery systems.

Note: GoMicro has not had a new release since April 2023, so likely it should be approached with caution.

Key Features

  • Pluggable Architecture: Adapt and extend GoMicro based on your project's needs.
  • Service Discovery & Load Balancing: Native integrations ensure efficient and smooth operations.

Benefits

  • Scalability: Designed with large-scale applications in mind, GoMicro can effortlessly manage increased loads.
  • Flexibility: The pluggable nature means it can be tailored to a variety of project requirements.

Limitations

  • Complexity: The wide range of features and pluggability can be daunting for newcomers.
  • Cloud-Native Dependency: May not be suitable for projects that aren't focused on cloud-native deployment.

Suitable for

  • For teams focusing on cloud-native applications, especially those benefiting from an event-driven approach.

When to consider GoMicro

  • When developing scalable, cloud-native, and event-driven applications.
  • When flexibility and customization of the framework are your primary priority, and investing signiticant time on manual infrastructure setup and maintenance is acceptable.

Go kit

Go kit

Go kit is a collection of Go packages (libraries) for building microservices in Go. It focuses on providing solutions to challenges commonly faced, while still remaining relatively unopinionated.

Key Features

  • Service Discovery: Integrates seamlessly with various service discovery systems.
  • Pluggable Transports: Offers a range of transport mechanisms like HTTP and gRPC.

Benefits

  • Standardization: Provides a uniform way of building services that adhere to best practices.
  • Flexibility: Despite being opinionated, it offers ways to plug in different components.

Limitations

  • Steep Learning Curve: Its specific way of doing things might require an initial investment in time to grasp.
  • Potential Overhead: For simpler projects, Go kit might seem overkill.

Suitable for

  • For teams that value standardization while maintaining flexibility.

When to consider Go kit

  • When you need a toolkit that balances standardizing an approaches with flexibility.
  • When you don't mind investing time and effort in manually setting up and maintaining cloud infrastructure and observability tooling.

Gin

Gin

Gin is a performance-focused web framework for Go. Minimalistic in nature, Gin is appropriate for building small, focused, applications.

Key Features

  • Performance: One of the fastest web frameworks for Go.
  • Middleware Support: Offers a range of middleware packages out of the box.

Benefits

  • Quick Start: Its minimalistic nature means you can get up and running quickly.
  • Versatility: Being minimal, Gin offers a lot of flexibility at the expense of built-in tooling.

Limitations

  • Web-Focused: Primarily tailored for web apps, might not be the best for non-web microservices.
  • Not as Feature-Rich: For more complex requirements, you may need to rely on third-party tools and extensions.

Suitable for

  • For developers and small teams who prioritize performance and want to create simple lightweight web applications.

When to consider Gin

  • When your project requires performance and the overall scope in small.
  • When you are building few and simple services, so the overall time investment in setting up infrastructure is small.

We hope this brief article helps inform your choice about which Go microservices framework to use in your project. Related to picking a framework, it's common to want to use an ORM to make it more efficient to use databases in your application. There are many ORMs to choose from, all with different characteristics. To help inform your decision, we've recently published a guide to the best Go ORMs.

Ready to escape the hamster wheel?

Encore is Backend Development Platform purpose-built for creating event-driven and distributed systems — from developing locally to scaling in your cloud on AWS/GCP.