Gin is a high-performance HTTP web framework written in Go. It provides a Martini-like API but with significantly better performance—up to 40 times faster—thanks to httprouter. Gin is designed for building REST APIs, web applications, and microservices.

★ 89,615⑂ 8,915👁 1,376⑃ 2,402● 2,415▤ 29◈ 22
GoMITCreated 2014-06-16gin-gonic.com/
89,615
stars
+10
8,915
forks
1,376
watchers
2,402
prs
2,415
issues
29
releases
22
discussions

README

Gin Web Framework












 📰 Gin 1.12.0 is now available!

We're excited to announce the release of Gin 1.12.0! This release brings new features, performance improvements, and important bug fixes. Check out the release announcement on our official blog for the full details.

---

Gin is a high-performance HTTP web framework written in Go. It provides a Martini-like API but with significantly better performance—up to 40 times faster—thanks to httprouter. Gin is designed for building REST APIs, web applications, and microservices where speed and developer productivity are essential.

Why choose Gin?

Gin combines the simplicity of Express.js-style routing with Go's performance characteristics, making it ideal for:

- Building high-throughput REST APIs
- Developing microservices that need to handle many concurrent requests
- Creating web applications that require fast response times
- Prototyping web services quickly with minimal boilerplate

Gin's key features:

- Zero allocation router - Extremely memory-efficient routing with no heap allocations
- High performance - Benchmarks show superior speed compared to other Go web frameworks
- Middleware support - Extensible middleware system for authentication, logging, CORS, etc.
- Crash-free - Built-in recovery middleware prevents panics from crashing your server
- JSON validation - Automatic request/response JSON binding and validation
- Route grouping - Organize related routes and apply common middleware
- Error management - Centralized error handling and logging
- Built-in rendering - Support for JSON, XML, HTML templates, and more
- Extensible - Large ecosystem of community middleware and plugins

 Getting Started

 Prerequisites

- Go version: Gin requires Go version 1.26 or above
- Basic Go knowledge: Familiarity with Go syntax and package management is helpful

 Installation

With Go's module support, simply import Gin in your code and Go will automatically fetch it during build:

go
import "github.com/gin-gonic/gin"


 Your First Gin Application

Here's a complete example that demonstrates Gin's simplicity:

go
package main

import (
  "log"
  "net/http"

  "github.com/gin-gonic/gin"
)

func main() {
  // Create a Gin router with default middleware (logger and recovery)
  r := gin.Default()

  // Define a simple GET endpoint
  r.GET("/ping", func(c gin.Context) {
    // Return JSON response
    c.JSON(http.StatusOK, gin.H{
      "message": "pong",
    })
  })

  // Start server on port 8080 (default)
  // Server will listen on 0.0.0.0:8080 (localhost:8080 on Windows)
  if err := r.Run(); err != nil {
    log.Fatalf("failed to run server: %v", err)
  }
}


Running the application:

1. Save the code above as main.go
2. Run the application:

   sh
   go run main.go
   

3. Open your browser and visit http://localhost:8080/ping
4. You should see: {"message":"pong"}

What this example demonstrates:

- Creating a Gin router with default middleware
- Defining HTTP endpoints with simple handler func

Top issues

Discussions

Latest release

v1.12.0 v1.12.0 2026-02-28
Changelog
 Features
 192ac89eefc1c30f7c97ae48a9ffb1c6f1c8c8bc: feat(binding): add support for encoding.UnmarshalText in uri/query binding (4203) (@takanuva15)
 53410d2e07054369e0960fbe2eed97e1b9966f12: feat(context): add GetError and GetErrorSlice methods for error retrieval (4502) (@raju-mechatronics)
 acc55e049e33b401e810dbd8c0d6dcb6b3ba2b05: feat(context): add Protocol Buffers support to content negotiation (4423) (@1911860538)
 38e765119241d990705169bedb5002a29ae0cbd1: feat(context): implemented Delete method (@Spyder01)
 771dcc6476d7bc6abb9ec0235ecefa4d38fe6fb0: feat(gin): add optio

Snapshot: 2026-11-10T09:35:25Z · Data license Apache-2.0 · JSON