gin-gonic/gin

Developer Tools

A high-performance Go HTTP framework for building REST APIs, web apps and microservices with routing and middleware.

89,444
8,829
Go
MIT
12 years old

Gin is a Go HTTP web framework for building REST APIs, web applications and microservices where request throughput and low overhead matter. It offers an Express.js/Martini-like routing API, so services can be prototyped with minimal boilerplate while running on Go's runtime.

What changes in practice

Instead of wiring handlers to Go's standard net/http mux, you create a router (for example gin.Default(), which includes logger and recovery middleware), register handlers per method and path, and return JSON, XML or HTML from a context object. Middleware is attached globally or per route group, which is how authentication, CORS, logging, metrics and tracing are typically added; the project points to the gin-contrib and gin-gonic/contrib collections for these middleware ecosystem.

The performance mechanism

The router is a customized httprouter, described as a zero-allocation router. In the README's GitHub-API routing benchmark, Gin reports 27,364 ns/op with 0 B/op and 0 allocs/op, while its own comparison table shows lower ns/op and allocation counts than most listed Go frameworks benchmark table. These are router-level benchmark numbers under stated conditions, not end-to-end application throughput for every workload; the README's "up to 40 times faster" figure is a framework comparison, not a promise for your service.

A concrete workflow

A minimal service looks like this: define a GET /ping handler that calls c.JSON with a status and a map, then call r.Run() to listen on port 8080 by default. The README walks through saving this as main.go, running it, and checking the response locally quick start. From there, the documented next steps are route grouping for shared middleware, JSON binding and validation, centralized error handling, and built-in renderers. Ready-made examples cover REST APIs, authentication, file uploads, WebSocket connections and templates in a separate example repository.

Requirements and scope

Gin requires Go 1.26 or later and basic familiarity with Go syntax and modules; dependencies are fetched automatically during build through Go modules prerequisites. The framework is MIT-licensed, so the main condition is retaining the licence notice; it does not impose a commercial restriction.

The README claims a "crash-free" property via built-in recovery middleware, which converts panics into handled responses rather than terminating the server. Treat that as the documented behaviour of the recovery middleware, not a guarantee that every failure mode is contained. The supplied material gives no detailed upgrade or rollback procedure; the latest noted release is Gin 1.12.0, and the release announcement is the place to check for migration details release announcement.

HotRepo's take

HotRepo's stored sample records Gin at #4 on the Go weekly board with +94 stars in the week ending 2026-10-28, across five recorded dates from 2026-10-24 to 2026-10-28. The available daily history is not comparable enough to judge whether interest is rising or fading; treat the board placement as a dated observation only.

Written by AI from the project's README, updated October 28, 2026. The project's own docs are the source of truth.

Hacker News

Gin is 40x faster than Martini
▲ 2 · 0 comments · August 7, 2022
Gin is a HTTP web framework written in Go (Golang)
▲ 1 · 0 comments · September 29, 2019
GHI: anyone know how to run golang gin with ssl?
▲ 1 · 0 comments · May 5, 2016