gin-gonic /gin
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
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 funcTop issues
#2535how to binding param and json 21 comments · 2020-10-20#2026How to access the context from a template function?17 comments · 2019-08-20#4278Why no call to Request.MultipartForm.RemoveAll12 comments · 2025-06-26#3501Can't get ClientIP run in AWS Lambda with gin12 comments · 2023-02-16#1985Middleware doesn't apply to Redirect12 comments · 2019-07-12#1898DefaultQuery of type int, float or bool12 comments · 2019-05-13#2811Is there a way to list all the required fields using gin-gonic11 comments · 2021-08-04#1847Huge dependency11 comments · 2019-04-06
Discussions
#4849Patch Release for CVE Fixes (CVE-2026-88031)4 comments · 2026-09-22#4780Proposal: Support the QUERY method.0 comments · 2026-07-31#4774RFC: Extract optional serialization formats from Gin core into gin-contrib0 comments · 2026-07-30#4736Consider making BSON support optional to avoid introducing the MongoDB driver as a core dependency1 comments · 2026-07-13#4719Proposal: Expose Middleware Information Through RouteInfo0 comments · 2026-06-28#4700[removed]0 comments · 2026-06-10#4649Embed Agent Friendly Code Score Badge0 comments · 2026-05-08#4589Changenotes — free AI changelog generator for gin0 comments · 2026-03-17
Latest release
v1.12.0 v1.12.0 2026-02-28Changelog 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
相关报道 (6)
www.80aj.comGitHub开源项目Codex2API遭遇账号封禁,API反代服务面临监管风险2026-06-02新浪财经_金融信息服务商刚刚,DeepSeek开始频繁更新:Tile Kernels、DeepEP V22026-04-23新浪财经基于昇腾RecSDK的生成式推荐实践,快速训练生成式推荐网络2026-01-2751CTO九个必备的Go语言GitHub库2024-02-26腾讯新闻M3 MacBook Pro 能提效?程序员、产品经理自证后,CTO:你赢了,新电脑在路上了2024-01-03Amazon Web Services (AWS)百尺竿头更进一步 – 拓展 Aurora的读写能力之Gaea篇2022-04-18
News & coverage (10)
Hacker NewsAsk HN: Which Go Web Framework (Pros and Cons)?▲ 16 · 12 comments · 2014-12-19Hacker NewsGin is 40x faster than Martini▲ 2 · 0 comments · 2022-08-07Hacker NewsExecute Gin, Iris, Gorilla or Whatever Else on AWS Lambda Seamlessly▲ 2 · 0 comments · 2016-11-04Hacker NewsGin is a HTTP web framework written in Go (Golang)▲ 1 · 0 comments · 2019-09-29Hacker NewsGHI: anyone know how to run golang gin with ssl?▲ 1 · 0 comments · 2016-05-05NVIDIA DeveloperFusing Communication and Compute with New Device API and Copy Engine Collectives in NVIDIA NCCL 2.282025-11-10The GitHub BlogModeling CORS frameworks with CodeQL to find security vulnerabilities2025-07-10NatureHow to establish and maintain a multimodal animal research dataset using DataLad2023-06-05infoq.comBuild, Test, and Deploy Scalable REST APIs in Go2022-11-02MakeUseOf5 Go Frameworks for Your Next Web App2022-08-26