Merge remote-tracking branch 'upstream/master'

This commit is contained in:
2025-07-09 14:40:09 +03:00
44 changed files with 1968 additions and 714 deletions
+38 -41
View File
@@ -1,46 +1,43 @@
# Gin Web Framework
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). If you need performance and good productivity, you will love Gin.
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).
If you need performance and good productivity, you will love Gin.
Copied from [gin-gonic/gin](https://github.com/gin-gonic/gin)
**The key features of Gin are:**
**Gin's key features are:**
- Zero allocation router
- Fast
- Speed
- Middleware support
- Crash-free
- JSON validation
- Routes grouping
- Route grouping
- Error management
- Rendering built-in
- Extendable
- Built-in rendering
- Extensible
## Getting started
### Prerequisites
- **[Go](https://go.dev/)**: any one of the **three latest major** [releases](https://go.dev/doc/devel/release) (we test it with these).
Gin requires [Go](https://go.dev/) version [1.21](https://go.dev/doc/devel/release#go1.21.0) or above.
### Getting Gin
With [Go module](https://github.com/golang/go/wiki/Modules) support, simply add the following import
```
import "git.company.lan/gopkg/gin"
```
to your code, and then `go [build|run|test]` will automatically fetch the necessary dependencies.
Otherwise, run the following Go command to install the `gin` package:
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:
```sh
$ go get -u git.company.lan/gopkg/gin
import "github.com/gin-gonic/gin"
```
Alternatively, use `go get`:
```sh
go get -u github.com/gin-gonic/gin
```
### Running Gin
First you need to import Gin package for using Gin, one simplest example likes the follow `example.go`:
A basic example:
```go
package main
@@ -62,28 +59,29 @@ func main() {
}
```
And use the Go command to run the demo:
To run the code, use the `go run` command, like:
```
# run example.go and visit 0.0.0.0:8080/ping on browser
```sh
$ go run example.go
```
### Learn more examples
Then visit [`0.0.0.0:8080/ping`](http://0.0.0.0:8080/ping) in your browser to see the response!
### See more examples
#### Quick Start
Learn and practice more examples, please read the [Gin Quick Start](docs/doc.md) which includes API examples and builds tag.
Learn and practice with the [Gin Quick Start](docs/doc.md), which includes API examples and builds tag.
#### Examples
A number of ready-to-run examples demonstrating various use cases of Gin on the [Gin examples](https://github.com/gin-gonic/examples) repository.
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.
## Documentation
See [API documentation and descriptions](https://godoc.org/github.com/gin-gonic/gin) for package.
See the [API documentation on go.dev](https://pkg.go.dev/github.com/gin-gonic/gin).
All documentation is available on the Gin website.
The documentation is also available on [gin-gonic.com](https://gin-gonic.com) in several languages:
- [English](https://gin-gonic.com/docs/)
- [简体中文](https://gin-gonic.com/zh-cn/docs/)
@@ -93,16 +91,15 @@ All documentation is available on the Gin website.
- [한국어](https://gin-gonic.com/ko-kr/docs/)
- [Turkish](https://gin-gonic.com/tr/docs/)
- [Persian](https://gin-gonic.com/fa/docs/)
- [Português](https://gin-gonic.com/pt/docs/)
### Articles about Gin
A curated list of awesome Gin framework.
### Articles
- [Tutorial: Developing a RESTful API with Go and Gin](https://go.dev/doc/tutorial/web-service-gin)
## Benchmarks
Gin uses a custom version of [HttpRouter](https://github.com/julienschmidt/httprouter), [see all benchmarks details](/BENCHMARKS.md).
Gin uses a custom version of [HttpRouter](https://github.com/julienschmidt/httprouter), [see all benchmarks](/BENCHMARKS.md).
| Benchmark name | (1) | (2) | (3) | (4) |
| ------------------------------ | --------: | --------------: | -----------: | --------------: |
@@ -142,23 +139,23 @@ Gin uses a custom version of [HttpRouter](https://github.com/julienschmidt/httpr
- (3): Heap Memory (B/op), lower is better
- (4): Average Allocations per Repetition (allocs/op), lower is better
## Middlewares
## Middleware
You can find many useful Gin middlewares at [gin-contrib](https://git.company.lan/gopkg/gin-contrib).
## Users
## Uses
Awesome project lists using [Gin](https://github.com/gin-gonic/gin) web framework.
Here are some awesome projects that are using the [Gin](https://github.com/gin-gonic/gin) web framework.
- [gorush](https://github.com/appleboy/gorush): A push notification server written in Go.
- [fnproject](https://github.com/fnproject/fn): The container native, cloud agnostic serverless platform.
- [photoprism](https://github.com/photoprism/photoprism): Personal photo management powered by Go and Google TensorFlow.
- [lura](https://github.com/luraproject/lura): Ultra performant API Gateway with middlewares.
- [picfit](https://github.com/thoas/picfit): An image resizing server written in Go.
- [gorush](https://github.com/appleboy/gorush): A push notification server.
- [fnproject](https://github.com/fnproject/fn): A container native, cloud agnostic serverless platform.
- [photoprism](https://github.com/photoprism/photoprism): Personal photo management powered by Google TensorFlow.
- [lura](https://github.com/luraproject/lura): Ultra performant API Gateway with middleware.
- [picfit](https://github.com/thoas/picfit): An image resizing server.
- [dkron](https://github.com/distribworks/dkron): Distributed, fault tolerant job scheduling system.
## Contributing
Gin is the work of hundreds of contributors. We appreciate your help!
Please see [CONTRIBUTING](CONTRIBUTING.md) for details on submitting patches and the contribution workflow.
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on submitting patches and the contribution workflow.