Guide · Open source
How to use Echo: install and build a Go web server
Updated · written with AI from the project's own documentation and checked against our catalogue data
Echo is an open-source web framework for the Go programming language, used to build web servers and APIs. It is built on Go's standard net/http package and adds a fast router, request data binding with validation, middleware and centralized error handling. This guide shows you how to install it, write a small server with routes and middleware, and know where to look next.
Quick start
- 1Check your Go install. Confirm Go is installed. Echo supports the three most recent Go releases.
- 2Install Echo. Run go get github.com/labstack/echo/v5 in your project folder.
- 3Create main.go. Write a main function that calls echo.New and registers a GET route.
- 4Add middleware. Attach RequestLogger and Recover with e.Use so requests are logged and panics are caught.
- 5Write a handler. Write a function that takes an echo context and returns c.String with a status code.
- 6Start the server. Call e.Start with a port such as :8080 and open it in your browser.
What Echo is and who it is for
Echo is a framework you write Go code with. It is not a finished application. It sits on top of Go's standard library and adds the parts the standard library leaves to you, such as a router, request binding, middleware and error handling.
It suits Go developers building REST APIs or backend services, and teams that want a small framework on top of the standard library. It assumes you already know Go, so it is not a good first programming language project.
- Good fit: Go developers building REST APIs or backend services
- Good fit: projects that need automatic TLS certificates via Let's Encrypt
- Not a fit: people who do not write Go, since it is a Go-only library
- Not a fit: finished applications that need no coding
Install Echo with go get
Echo is installed as a Go package with the go get command. You need Go installed first. The README says the current release supports the three most recent Go releases and may work with older ones.
Run the install command in your Go project folder. The import path includes /v5, which is the current release line of the library.
go get github.com/labstack/echo/v5Write your first Echo server
Create a Go file, import Echo and the middleware package, create an Echo instance with echo.New, register a route and start the server on a port. The handler receives an echo context and returns a response. This example starts a server on port 8080 that replies with Hello, World! at the root path.
The example also adds two middleware: RequestLogger, which logs requests with log/slog, and Recover, which recovers from panics and returns an error. Run the program and open http://localhost:8080 in a browser to see the response.
package main
import (
"log/slog"
"net/http"
"github.com/labstack/echo/v5"
"github.com/labstack/echo/v5/middleware"
)
func main() {
e := echo.New()
e.Use(middleware.RequestLogger())
e.Use(middleware.Recover())
e.GET("/", hello)
if err := e.Start(":8080"); err != nil {
slog.Error("failed to start server", "error", err)
}
}
func hello(c *echo.Context) error {
return c.String(http.StatusOK, "Hello, World!")
}Use routes, groups and middleware
Echo has a fast radix-tree router that prioritizes routes. You register handlers with methods such as GET on the instance, and you can group routes so they share a prefix and middleware. Middleware can be attached at the root, group or route level.
Echo provides an official set of middleware in separate repositories. For example, echo-jwt handles JWT authentication, echo-prometheus provides Prometheus metrics, and echo-otel provides OpenTelemetry tracing and metrics. Third-party middleware is also listed, including logging and HTTP cache options, but those projects are maintained by their authors and should be reviewed before use.
- Route groups share a path prefix and middleware
- Middleware can run at root, group or route level
- Official middleware covers JWT auth, Prometheus, OpenTelemetry and pprof via echo-contrib
Bind request data and handle errors
Echo can bind data from JSON, XML, forms, query strings and path parameters into Go structs, with pluggable validation. Responses can be JSON, XML, HTML, files or streams through helper functions.
Errors can be handled in one central place rather than in every handler, which keeps API error responses consistent.
- Binding sources: JSON, XML, form, query and path parameters
- Response helpers: JSON, XML, HTML, file and stream
- Centralized error handling is a built-in feature
Run Echo over HTTPS
Echo supports TLS and HTTP/2. It also supports automatic TLS certificates from Let's Encrypt, and graceful shutdown. The README points to cookbook pages for each of these, which show the setup in detail.
For production, read the auto-TLS and graceful shutdown cookbook pages on the official site before deploying.
- TLS and HTTP/2 support
- Automatic TLS with Let's Encrypt
- Graceful shutdown
What people use it for
- A REST API that accepts JSON and validates request bodies
- A backend service with JWT-protected routes using echo-jwt
- A small HTTPS service that gets certificates automatically from Let's Encrypt
- An internal service with Prometheus metrics added through echo-prometheus
Frequently asked questions
Is Echo free to use?
Echo is released under the MIT licence, so you can use it in open-source and commercial projects. The README also mentions Echo Pro, a separate commercial library, which is optional and not required to use Echo.
What do I need before installing Echo?
You need Go installed. The README says Echo supports the three most recent Go releases and may work with older ones. Install it with go get github.com/labstack/echo/v5.
Can I use Echo without knowing Go?
No. Echo is a Go-only library and assumes Go knowledge. People with no programming background should learn basic Go first.
What is the difference between Echo and Gin, Chi, Fiber or Gorilla Mux?
Echo, Gin, Chi, Fiber and Gorilla Mux are all Go web libraries used to build servers and APIs. Echo is built on the standard net/http package and includes binding, validation, middleware and error handling. This page does not benchmark them, so compare features and API style on each project's own pages before choosing.
Why is my Echo server not starting?
The example logs a failure message with log/slog if e.Start returns an error. Check that the port, such as :8080, is free and that the error text in the log is correct. The README points to GitHub Discussions for help and questions.
Does Echo support HTTPS?
Yes. Echo supports TLS, HTTP/2 and automatic TLS certificates from Let's Encrypt, as listed in its features.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Echo suits Go developers who want a small, fast framework on top of the standard library for REST APIs and backend services. It is a poor choice for people who do not write Go, beginners without programming experience, or anyone who needs a finished application rather than a framework to build one.
Install options & downloads