docs(readme): revamp and expand documentation for clarity and completeness (#4362)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
- Update contributing header to single hash style - Remove deprecated badge and improve project summary wording - Reorganize and clarify feature descriptions and benefits - Restructure getting started and installation instructions for clarity - Expand and annotate the first example application walkthrough - Detail the steps for running the sample application and expected output - Improve guidance on learning resources and example projects - Enhance API reference, documentation links, and tutorial references - Add a clear performance benchmarks section comparing Gin to other frameworks - Expand middleware section with ecosystem highlights and usage details - Create a production usage section listing notable projects using Gin - Revamp contribution section with clearer procedure and encouragement for new contributors
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Signed-off-by: appleboy <appleboy.tw@gmail.com>
Diff stats
2 files+113 added−69 removed
- other:+113 added−69 removed
Provenance
- Commit
4dd00f8- Tree
c80e728- Author
Bo-Yi Wu <appleboy.tw@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
6ad6205
2 files changed+113 added−69 removed
modified:CONTRIBUTING.md+1 added-1 removed
1123458 unmodified lines## Contributing# Contributing
- With issues: - Use the search tool before opening a new issue. - Please provide source code and commit sha if you found a bug.8 unmodified linesmodified:README.md+112 added-68 removed
7 unmodified lines8 [](https://pkg.go.dev/github.com/gin-gonic/gin?tab=doc)9 [](https://sourcegraph.com/github.com/gin-gonic/gin?badge)10 [](https://www.codetriage.com/gin-gonic/gin)11 [](https://github.com/gin-gonic/gin/releases)12-[](https://www.tickgit.com/browse?repo=github.com/gin-gonic/gin)12 14-Gin is a web framework written in [Go](https://go.dev/). It features a martini-like API with performance that is up to 40 times faster thanks to [httprouter](https://github.com/julienschmidt/httprouter).15-If you need performance and good productivity, you will love Gin.13+Gin 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.14 17-**Gin's key features are:**15+**Why choose Gin?**16 19-- Zero allocation router20-- Speed21-- Middleware support22-- Crash-free23-- JSON validation24-- Route grouping25-- Error management26-- Built-in rendering27-- Extensible17+Gin combines the simplicity of Express.js-style routing with Go's performance characteristics, making it ideal for:18 29-## Getting started19+- Building high-throughput REST APIs20+- Developing microservices that need to handle many concurrent requests21+- Creating web applications that require fast response times22+- Prototyping web services quickly with minimal boilerplate23 24+**Gin's key features:**25+26+- **Zero allocation router** - Extremely memory-efficient routing with no heap allocations27+- **High performance** - Benchmarks show superior speed compared to other Go web frameworks28+- **Middleware support** - Extensible middleware system for authentication, logging, CORS, etc.29+- **Crash-free** - Built-in recovery middleware prevents panics from crashing your server30+- **JSON validation** - Automatic request/response JSON binding and validation31+- **Route grouping** - Organize related routes and apply common middleware32+- **Error management** - Centralized error handling and logging33+- **Built-in rendering** - Support for JSON, XML, HTML templates, and more34+- **Extensible** - Large ecosystem of community middleware and plugins35+36+## Getting Started37+38 ### Prerequisites39 33-Gin requires [Go](https://go.dev/) version [1.23](https://go.dev/doc/devel/release#go1.23.0) or above.40+- **Go version**: Gin requires [Go](https://go.dev/) version [1.23](https://go.dev/doc/devel/release#go1.23.0) or above41+- **Basic Go knowledge**: Familiarity with Go syntax and package management is helpful42 35-### Getting Gin43+### Installation44 37-With [Go's module support](https://go.dev/wiki/Modules#how-to-use-modules), `go [build|run|test]` automatically fetches the necessary dependencies when you add the import in your code:45+With [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:46 39-```sh47+```go48 import "github.com/gin-gonic/gin"49 ```50 43-Alternatively, use `go get`:51+### Your First Gin Application52 45-```sh46-go get -u github.com/gin-gonic/gin47-```53+Here's a complete example that demonstrates Gin's simplicity:54 49-### Running Gin50-51-A basic example:52-55 ```go56 package main57 58 import (2 unmodified lines61 "github.com/gin-gonic/gin"62 )63 64 func main() {65+ // Create a Gin router with default middleware (logger and recovery)66 r := gin.Default()67+ 68+ // Define a simple GET endpoint69 r.GET("/ping", func(c *gin.Context) {70+ // Return JSON response71 c.JSON(http.StatusOK, gin.H{72 "message": "pong",73 })74 })69- r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")75+ 76+ // Start server on port 8080 (default)77+ // Server will listen on 0.0.0.0:8080 (localhost:8080 on Windows)78+ r.Run()79 }80 ```81 73-To run the code, use the `go run` command, like:82+**Running the application:**83 75-```sh76-go run example.go77-```84+1. Save the code above as `main.go`85+2. Run the application:86 79-Then visit [`0.0.0.0:8080/ping`](http://0.0.0.0:8080/ping) in your browser to see the response!87+ ```sh88+ go run main.go89+ ```90 81-### See more examples91+3. Open your browser and visit [`http://localhost:8080/ping`](http://localhost:8080/ping)92+4. You should see: `{"message":"pong"}`93 83-#### Quick Start94+**What this example demonstrates:**95 85-Learn and practice with the [Gin Quick Start](docs/doc.md), which includes API examples and builds tag.96+- Creating a Gin router with default middleware97+- Defining HTTP endpoints with simple handler functions98+- Returning JSON responses99+- Starting an HTTP server100 87-#### Examples101+### Next Steps102 89-A number of ready-to-run examples demonstrating various use cases of Gin are available in the [Gin examples](https://github.com/gin-gonic/examples) repository.103+After running your first Gin application, explore these resources to learn more:104 91-## Documentation105+#### 📚 Learning Resources106 93-See the [API documentation on go.dev](https://pkg.go.dev/github.com/gin-gonic/gin).107+- **[Gin Quick Start Guide](docs/doc.md)** - Comprehensive tutorial with API examples and build configurations108+- **[Example Repository](https://github.com/gin-gonic/examples)** - Ready-to-run examples demonstrating various Gin use cases:109+ - REST API development110+ - Authentication & middleware111+ - File uploads and downloads112+ - WebSocket connections113+ - Template rendering114 95-The documentation is also available on [gin-gonic.com](https://gin-gonic.com) in several languages:115+## 📖 Documentation116 97-- [English](https://gin-gonic.com/en/docs/)98-- [简体中文](https://gin-gonic.com/zh-cn/docs/)99-- [繁體中文](https://gin-gonic.com/zh-tw/docs/)100-- [日本語](https://gin-gonic.com/ja/docs/)101-- [Español](https://gin-gonic.com/es/docs/)102-- [한국어](https://gin-gonic.com/ko-kr/docs/)103-- [Turkish](https://gin-gonic.com/tr/docs/)104-- [Persian](https://gin-gonic.com/fa/docs/)105-- [Português](https://gin-gonic.com/pt/docs/)106-- [Russian](https://gin-gonic.com/ru/docs/)107-- [Indonesian](https://gin-gonic.com/id/docs/)117+### API Reference118 109-### Articles119+- **[Go.dev API Documentation](https://pkg.go.dev/github.com/gin-gonic/gin)** - Complete API reference with examples120 111-- [Tutorial: Developing a RESTful API with Go and Gin](https://go.dev/doc/tutorial/web-service-gin)121+### User Guides122 113-## Benchmarks123+The comprehensive documentation is available on [gin-gonic.com](https://gin-gonic.com) in multiple languages:124 115-Gin uses a custom version of [HttpRouter](https://github.com/julienschmidt/httprouter), [see all benchmarks](/BENCHMARKS.md).125+- [English](https://gin-gonic.com/en/docs/) | [简体中文](https://gin-gonic.com/zh-cn/docs/) | [繁體中文](https://gin-gonic.com/zh-tw/docs/)126+- [日本語](https://gin-gonic.com/ja/docs/) | [한국어](https://gin-gonic.com/ko-kr/docs/) | [Español](https://gin-gonic.com/es/docs/)127+- [Turkish](https://gin-gonic.com/tr/docs/) | [Persian](https://gin-gonic.com/fa/docs/) | [Português](https://gin-gonic.com/pt/docs/)128+- [Russian](https://gin-gonic.com/ru/docs/) | [Indonesian](https://gin-gonic.com/id/docs/)129 130+### Official Tutorials131+132+- [Go.dev Tutorial: Developing a RESTful API with Go and Gin](https://go.dev/doc/tutorial/web-service-gin)133+134+## ⚡ Performance Benchmarks135+136+Gin 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)137+138+**Gin vs. Other Go Frameworks** (GitHub API routing benchmark):139+140 | Benchmark name | (1) | (2) | (3) | (4) |141 | ------------------------------ | --------: | --------------: | -----------: | --------------: |142 | BenchmarkGin_GithubAll | **43550** | **27364 ns/op** | **0 B/op** | **0 allocs/op** |143 | BenchmarkAce_GithubAll | 40543 | 29670 ns/op | 0 B/op | 0 allocs/op |30 unmodified lines174 - (2): Single Repetition Duration (ns/op), lower is better175 - (3): Heap Memory (B/op), lower is better176 - (4): Average Allocations per Repetition (allocs/op), lower is better177 155-## Middleware178+## 🔌 Middleware Ecosystem179 157-You can find many useful Gin middlewares at [gin-contrib](https://github.com/gin-contrib) and [gin-gonic/contrib](https://github.com/gin-gonic/contrib).180+Gin has a rich ecosystem of middleware for common web development needs. Explore community-contributed middleware:181 159-## Uses182+- **[gin-contrib](https://github.com/gin-contrib)** - Official middleware collection including:183+ - Authentication (JWT, Basic Auth, Sessions)184+ - CORS, Rate limiting, Compression185+ - Logging, Metrics, Tracing186+ - Static file serving, Template engines187+ 188+- **[gin-gonic/contrib](https://github.com/gin-gonic/contrib)** - Additional community middleware189 161-Here are some awesome projects that are using the [Gin](https://github.com/gin-gonic/gin) web framework.190+## 🏢 Production Usage191 163-- [gorush](https://github.com/appleboy/gorush): A push notification server.164-- [fnproject](https://github.com/fnproject/fn): A container native, cloud agnostic serverless platform.165-- [photoprism](https://github.com/photoprism/photoprism): Personal photo management powered by Google TensorFlow.166-- [lura](https://github.com/luraproject/lura): Ultra performant API Gateway with middleware.167-- [picfit](https://github.com/thoas/picfit): An image resizing server.168-- [dkron](https://github.com/distribworks/dkron): Distributed, fault tolerant job scheduling system.192+Gin powers many high-traffic applications and services in production:193 170-## Contributing194+- **[gorush](https://github.com/appleboy/gorush)** - High-performance push notification server195+- **[fnproject](https://github.com/fnproject/fn)** - Container-native, serverless platform196+- **[photoprism](https://github.com/photoprism/photoprism)** - AI-powered personal photo management197+- **[lura](https://github.com/luraproject/lura)** - Ultra-performant API Gateway framework198+- **[picfit](https://github.com/thoas/picfit)** - Real-time image processing server199+- **[dkron](https://github.com/distribworks/dkron)** - Distributed job scheduling system200 172-Gin is the work of hundreds of contributors. We appreciate your help!201+## 🤝 Contributing202 174-Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on submitting patches and the contribution workflow.203+Gin is the work of hundreds of contributors from around the world. We welcome and appreciate your contributions!204+205+### How to Contribute206+207+- 🐛 **Report bugs** - Help us identify and fix issues208+- 💡 **Suggest features** - Share your ideas for improvements209+- 📝 **Improve documentation** - Help make our docs clearer210+- 🔧 **Submit code** - Fix bugs or implement new features211+- 🧪 **Write tests** - Improve our test coverage212+213+### Getting Started with Contributing214+215+1. Check out our [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines216+2. Join our community discussions and ask questions217+218+**All contributions are valued and help make Gin better for everyone!**