{"id":13416625,"url":"https://github.com/gin-gonic/gin","last_synced_at":"2025-11-12T21:43:10.326Z","repository":{"id":17930856,"uuid":"20904437","full_name":"gin-gonic/gin","owner":"gin-gonic","description":"Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.","archived":false,"fork":false,"pushed_at":"2025-05-05T23:35:55.000Z","size":3634,"stargazers_count":82118,"open_issues_count":857,"forks_count":8188,"subscribers_count":1364,"default_branch":"master","last_synced_at":"2025-05-07T07:18:18.897Z","etag":null,"topics":["framework","gin","go","middleware","performance","router","server"],"latest_commit_sha":null,"homepage":"https://gin-gonic.com/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gin-gonic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-06-16T23:57:25.000Z","updated_at":"2025-05-07T06:12:21.000Z","dependencies_parsed_at":"2023-01-16T21:01:12.135Z","dependency_job_id":"8c54a0d6-04c6-4003-9b3e-efa9e171320b","html_url":"https://github.com/gin-gonic/gin","commit_stats":{"total_commits":1578,"total_committers":469,"mean_commits":"3.3646055437100215","dds":0.7667934093789607,"last_synced_commit":"c8a3adc65703d8958265c07689662e54f037038c"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-gonic%2Fgin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-gonic%2Fgin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-gonic%2Fgin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gin-gonic%2Fgin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gin-gonic","download_url":"https://codeload.github.com/gin-gonic/gin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253757235,"owners_count":21959365,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["framework","gin","go","middleware","performance","router","server"],"created_at":"2024-07-30T22:00:17.362Z","updated_at":"2025-11-12T21:43:10.320Z","avatar_url":"https://github.com/gin-gonic.png","language":"Go","readme":"# Gin Web Framework\n\n\u003cimg align=\"right\" width=\"159px\" src=\"https://raw.githubusercontent.com/gin-gonic/logo/master/color.png\"\u003e\n\n[![Build Status](https://github.com/gin-gonic/gin/actions/workflows/gin.yml/badge.svg?branch=master)](https://github.com/gin-gonic/gin/actions/workflows/gin.yml)\n[![Trivy Security Scan](https://github.com/gin-gonic/gin/actions/workflows/trivy-scan.yml/badge.svg)](https://github.com/gin-gonic/gin/actions/workflows/trivy-scan.yml)\n[![codecov](https://codecov.io/gh/gin-gonic/gin/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-gonic/gin)\n[![Go Report Card](https://goreportcard.com/badge/github.com/gin-gonic/gin)](https://goreportcard.com/report/github.com/gin-gonic/gin)\n[![Go Reference](https://pkg.go.dev/badge/github.com/gin-gonic/gin?status.svg)](https://pkg.go.dev/github.com/gin-gonic/gin?tab=doc)\n[![Sourcegraph](https://sourcegraph.com/github.com/gin-gonic/gin/-/badge.svg)](https://sourcegraph.com/github.com/gin-gonic/gin?badge)\n[![Open Source Helpers](https://www.codetriage.com/gin-gonic/gin/badges/users.svg)](https://www.codetriage.com/gin-gonic/gin)\n[![Release](https://img.shields.io/github/release/gin-gonic/gin.svg?style=flat-square)](https://github.com/gin-gonic/gin/releases)\n\n## 📰 [Announcing Gin 1.11.0!](https://gin-gonic.com/en/blog/news/gin-1-11-0-release-announcement/)\n\nRead about the latest features and improvements in Gin 1.11.0 on our official blog.\n\n---\n\nGin is a high-performance HTTP web framework written in [Go](https://go.dev/). It provides a Martini-like API but with significantly better performance—up to 40 times faster—thanks to [httprouter](https://github.com/julienschmidt/httprouter). Gin is designed for building REST APIs, web applications, and microservices where speed and developer productivity are essential.\n\n**Why choose Gin?**\n\nGin combines the simplicity of Express.js-style routing with Go's performance characteristics, making it ideal for:\n\n- Building high-throughput REST APIs\n- Developing microservices that need to handle many concurrent requests\n- Creating web applications that require fast response times\n- Prototyping web services quickly with minimal boilerplate\n\n**Gin's key features:**\n\n- **Zero allocation router** - Extremely memory-efficient routing with no heap allocations\n- **High performance** - Benchmarks show superior speed compared to other Go web frameworks\n- **Middleware support** - Extensible middleware system for authentication, logging, CORS, etc.\n- **Crash-free** - Built-in recovery middleware prevents panics from crashing your server\n- **JSON validation** - Automatic request/response JSON binding and validation\n- **Route grouping** - Organize related routes and apply common middleware\n- **Error management** - Centralized error handling and logging\n- **Built-in rendering** - Support for JSON, XML, HTML templates, and more\n- **Extensible** - Large ecosystem of community middleware and plugins\n\n## Getting Started\n\n### Prerequisites\n\n- **Go version**: Gin requires [Go](https://go.dev/) version [1.24](https://go.dev/doc/devel/release#go1.24.0) or above\n- **Basic Go knowledge**: Familiarity with Go syntax and package management is helpful\n\n### Installation\n\nWith [Go's module support](https://go.dev/wiki/Modules#how-to-use-modules), simply import Gin in your code and Go will automatically fetch it during build:\n\n```go\nimport \"github.com/gin-gonic/gin\"\n```\n\n### Your First Gin Application\n\nHere's a complete example that demonstrates Gin's simplicity:\n\n```go\npackage main\n\nimport (\n  \"log\"\n  \"net/http\"\n\n  \"github.com/gin-gonic/gin\"\n)\n\nfunc main() {\n  // Create a Gin router with default middleware (logger and recovery)\n  r := gin.Default()\n\n  // Define a simple GET endpoint\n  r.GET(\"/ping\", func(c *gin.Context) {\n    // Return JSON response\n    c.JSON(http.StatusOK, gin.H{\n      \"message\": \"pong\",\n    })\n  })\n\n  // Start server on port 8080 (default)\n  // Server will listen on 0.0.0.0:8080 (localhost:8080 on Windows)\n  if err := r.Run(); err != nil {\n    log.Fatalf(\"failed to run server: %v\", err)\n  }\n}\n```\n\n**Running the application:**\n\n1. Save the code above as `main.go`\n2. Run the application:\n\n   ```sh\n   go run main.go\n   ```\n\n3. Open your browser and visit [`http://localhost:8080/ping`](http://localhost:8080/ping)\n4. You should see: `{\"message\":\"pong\"}`\n\n**What this example demonstrates:**\n\n- Creating a Gin router with default middleware\n- Defining HTTP endpoints with simple handler functions\n- Returning JSON responses\n- Starting an HTTP server\n\n### Next Steps\n\nAfter running your first Gin application, explore these resources to learn more:\n\n#### 📚 Learning Resources\n\n- **[Gin Quick Start Guide](docs/doc.md)** - Comprehensive tutorial with API examples and build configurations\n- **[Example Repository](https://github.com/gin-gonic/examples)** - Ready-to-run examples demonstrating various Gin use cases:\n  - REST API development\n  - Authentication \u0026 middleware\n  - File uploads and downloads\n  - WebSocket connections\n  - Template rendering\n\n## 📖 Documentation\n\n### API Reference\n\n- **[Go.dev API Documentation](https://pkg.go.dev/github.com/gin-gonic/gin)** - Complete API reference with examples\n\n### User Guides\n\nThe comprehensive documentation is available on [gin-gonic.com](https://gin-gonic.com) in multiple languages:\n\n- [English](https://gin-gonic.com/en/docs/) | [简体中文](https://gin-gonic.com/zh-cn/docs/) | [繁體中文](https://gin-gonic.com/zh-tw/docs/)\n- [日本語](https://gin-gonic.com/ja/docs/) | [한국어](https://gin-gonic.com/ko-kr/docs/) | [Español](https://gin-gonic.com/es/docs/)\n- [Turkish](https://gin-gonic.com/tr/docs/) | [Persian](https://gin-gonic.com/fa/docs/) | [Português](https://gin-gonic.com/pt/docs/)\n- [Russian](https://gin-gonic.com/ru/docs/) | [Indonesian](https://gin-gonic.com/id/docs/)\n\n### Official Tutorials\n\n- [Go.dev Tutorial: Developing a RESTful API with Go and Gin](https://go.dev/doc/tutorial/web-service-gin)\n\n## ⚡ Performance Benchmarks\n\nGin demonstrates exceptional performance compared to other Go web frameworks. It uses a custom version of [HttpRouter](https://github.com/julienschmidt/httprouter) for maximum efficiency. [View detailed benchmarks →](/BENCHMARKS.md)\n\n**Gin vs. Other Go Frameworks** (GitHub API routing benchmark):\n\n| Benchmark name                 |       (1) |             (2) |          (3) |             (4) |\n| ------------------------------ | --------: | --------------: | -----------: | --------------: |\n| BenchmarkGin_GithubAll         | **43550** | **27364 ns/op** |   **0 B/op** | **0 allocs/op** |\n| BenchmarkAce_GithubAll         |     40543 |     29670 ns/op |       0 B/op |     0 allocs/op |\n| BenchmarkAero_GithubAll        |     57632 |     20648 ns/op |       0 B/op |     0 allocs/op |\n| BenchmarkBear_GithubAll        |      9234 |    216179 ns/op |   86448 B/op |   943 allocs/op |\n| BenchmarkBeego_GithubAll       |      7407 |    243496 ns/op |   71456 B/op |   609 allocs/op |\n| BenchmarkBone_GithubAll        |       420 |   2922835 ns/op |  720160 B/op |  8620 allocs/op |\n| BenchmarkChi_GithubAll         |      7620 |    238331 ns/op |   87696 B/op |   609 allocs/op |\n| BenchmarkDenco_GithubAll       |     18355 |     64494 ns/op |   20224 B/op |   167 allocs/op |\n| BenchmarkEcho_GithubAll        |     31251 |     38479 ns/op |       0 B/op |     0 allocs/op |\n| BenchmarkGocraftWeb_GithubAll  |      4117 |    300062 ns/op |  131656 B/op |  1686 allocs/op |\n| BenchmarkGoji_GithubAll        |      3274 |    416158 ns/op |   56112 B/op |   334 allocs/op |\n| BenchmarkGojiv2_GithubAll      |      1402 |    870518 ns/op |  352720 B/op |  4321 allocs/op |\n| BenchmarkGoJsonRest_GithubAll  |      2976 |    401507 ns/op |  134371 B/op |  2737 allocs/op |\n| BenchmarkGoRestful_GithubAll   |       410 |   2913158 ns/op |  910144 B/op |  2938 allocs/op |\n| BenchmarkGorillaMux_GithubAll  |       346 |   3384987 ns/op |  251650 B/op |  1994 allocs/op |\n| BenchmarkGowwwRouter_GithubAll |     10000 |    143025 ns/op |   72144 B/op |   501 allocs/op |\n| BenchmarkHttpRouter_GithubAll  |     55938 |     21360 ns/op |       0 B/op |     0 allocs/op |\n| BenchmarkHttpTreeMux_GithubAll |     10000 |    153944 ns/op |   65856 B/op |   671 allocs/op |\n| BenchmarkKocha_GithubAll       |     10000 |    106315 ns/op |   23304 B/op |   843 allocs/op |\n| BenchmarkLARS_GithubAll        |     47779 |     25084 ns/op |       0 B/op |     0 allocs/op |\n| BenchmarkMacaron_GithubAll     |      3266 |    371907 ns/op |  149409 B/op |  1624 allocs/op |\n| BenchmarkMartini_GithubAll     |       331 |   3444706 ns/op |  226551 B/op |  2325 allocs/op |\n| BenchmarkPat_GithubAll         |       273 |   4381818 ns/op | 1483152 B/op | 26963 allocs/op |\n| BenchmarkPossum_GithubAll      |     10000 |    164367 ns/op |   84448 B/op |   609 allocs/op |\n| BenchmarkR2router_GithubAll    |     10000 |    160220 ns/op |   77328 B/op |   979 allocs/op |\n| BenchmarkRivet_GithubAll       |     14625 |     82453 ns/op |   16272 B/op |   167 allocs/op |\n| BenchmarkTango_GithubAll       |      6255 |    279611 ns/op |   63826 B/op |  1618 allocs/op |\n| BenchmarkTigerTonic_GithubAll  |      2008 |    687874 ns/op |  193856 B/op |  4474 allocs/op |\n| BenchmarkTraffic_GithubAll     |       355 |   3478508 ns/op |  820744 B/op | 14114 allocs/op |\n| BenchmarkVulcan_GithubAll      |      6885 |    193333 ns/op |   19894 B/op |   609 allocs/op |\n\n- (1): Total Repetitions achieved in constant time, higher means more confident result\n- (2): Single Repetition Duration (ns/op), lower is better\n- (3): Heap Memory (B/op), lower is better\n- (4): Average Allocations per Repetition (allocs/op), lower is better\n\n## 🔌 Middleware Ecosystem\n\nGin has a rich ecosystem of middleware for common web development needs. Explore community-contributed middleware:\n\n- **[gin-contrib](https://github.com/gin-contrib)** - Official middleware collection including:\n  - Authentication (JWT, Basic Auth, Sessions)\n  - CORS, Rate limiting, Compression\n  - Logging, Metrics, Tracing\n  - Static file serving, Template engines\n- **[gin-gonic/contrib](https://github.com/gin-gonic/contrib)** - Additional community middleware\n\n## 🏢 Production Usage\n\nGin powers many high-traffic applications and services in production:\n\n- **[gorush](https://github.com/appleboy/gorush)** - High-performance push notification server\n- **[fnproject](https://github.com/fnproject/fn)** - Container-native, serverless platform\n- **[photoprism](https://github.com/photoprism/photoprism)** - AI-powered personal photo management\n- **[lura](https://github.com/luraproject/lura)** - Ultra-performant API Gateway framework\n- **[picfit](https://github.com/thoas/picfit)** - Real-time image processing server\n- **[dkron](https://github.com/distribworks/dkron)** - Distributed job scheduling system\n\n## 🤝 Contributing\n\nGin is the work of hundreds of contributors from around the world. We welcome and appreciate your contributions!\n\n### How to Contribute\n\n- 🐛 **Report bugs** - Help us identify and fix issues\n- 💡 **Suggest features** - Share your ideas for improvements\n- 📝 **Improve documentation** - Help make our docs clearer\n- 🔧 **Submit code** - Fix bugs or implement new features\n- 🧪 **Write tests** - Improve our test coverage\n\n### Getting Started with Contributing\n\n1. Check out our [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines\n2. Join our community discussions and ask questions\n\n**All contributions are valued and help make Gin better for everyone!**\n","funding_links":[],"categories":["Go","Popular","Uncategorized","开源类库","HTTP","Misc","Awesome","Dependencies","RESTful API Server builders \u0026 generators","web  框架","Open source library","[Go](#go)","Web Frameworks","Service Toolkits","Go (531)","语言资源库","后端开发框架及项目","Web Development","白盒测试","web框架","Go의 웹 프레임워크","Programming technologies","Programming Languages","HarmonyOS","Back-End Development","web框架`web 框架`","后端","REST Framework","武器库","Utility","开发工具\u0026框架","Web 框架","Web框架"],"sub_categories":["Uncategorized","Web 框架","Web Framework","Utility/Miscellaneous","Go","go","HTTP Clients","管理面板","常见开发框架","版本控制","GOPATH","Frameworks","Windows Manager","Advanced Console UIs","版本控制`版本控制相关库`","图像","Resource Management","Fail injection","后端","实用程序/Miscellaneous","交流","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgin-gonic%2Fgin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgin-gonic%2Fgin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgin-gonic%2Fgin/lists"}