gin-gonic

    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.

    backend
    framework
    gin
    go
    middleware
    performance
    router
    server
    Go
    MIT
    88.2K stars
    8.6K forks
    88.2K watching
    Updated 2/27/2026
    View on GitHub
    Backblaze Advertisement

    Loading star history...

    Health Score

    75

    Weekly Growth

    +0

    +0.0% this week

    Contributors

    1

    Total contributors

    Open Issues

    659

    Generated Insights

    About gin

    Gin Web Framework

    Build Status codecov Go Report Card Go Reference Sourcegraph Open Source Helpers Release TODOs

    Gin is a web framework written in Go. It features a martini-like API with performance that is up to 40 times faster thanks to httprouter. If you need performance and good productivity, you will love Gin.

    Gin's key features are:

    • Zero allocation router
    • Speed
    • Middleware support
    • Crash-free
    • JSON validation
    • Route grouping
    • Error management
    • Built-in rendering
    • Extensible

    Getting started

    Prerequisites

    Gin requires Go version 1.23 or above.

    Getting Gin

    With Go's module support, go [build|run|test] automatically fetches the necessary dependencies when you add the import in your code:

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

    Alternatively, use go get:

    go get -u github.com/gin-gonic/gin
    

    Running Gin

    A basic example:

    package main
    
    import (
      "net/http"
    
      "github.com/gin-gonic/gin"
    )
    
    func main() {
      r := gin.Default()
      r.GET("/ping", func(c *gin.Context) {
        c.JSON(http.StatusOK, gin.H{
          "message": "pong",
        })
      })
      r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
    }
    

    To run the code, use the go run command, like:

    go run example.go
    

    Then visit 0.0.0.0:8080/ping in your browser to see the response!

    See more examples

    Quick Start

    Learn and practice with the Gin Quick Start, which includes API examples and builds tag.

    Examples

    A number of ready-to-run examples demonstrating various use cases of Gin are available in the Gin examples repository.

    Documentation

    See the API documentation on go.dev.

    The documentation is also available on gin-gonic.com in several languages:

    Articles

    Benchmarks

    Gin uses a custom version of HttpRouter, see all benchmarks.

    Benchmark name(1)(2)(3)(4)
    BenchmarkGin_GithubAll4355027364 ns/op0 B/op0 allocs/op
    BenchmarkAce_GithubAll4054329670 ns/op0 B/op0 allocs/op
    BenchmarkAero_GithubAll5763220648 ns/op0 B/op0 allocs/op
    BenchmarkBear_GithubAll9234216179 ns/op86448 B/op943 allocs/op
    BenchmarkBeego_GithubAll7407243496 ns/op71456 B/op609 allocs/op
    BenchmarkBone_GithubAll4202922835 ns/op720160 B/op8620 allocs/op
    BenchmarkChi_GithubAll7620238331 ns/op87696 B/op609 allocs/op
    BenchmarkDenco_GithubAll1835564494 ns/op20224 B/op167 allocs/op
    BenchmarkEcho_GithubAll3125138479 ns/op0 B/op0 allocs/op
    BenchmarkGocraftWeb_GithubAll4117300062 ns/op131656 B/op1686 allocs/op
    BenchmarkGoji_GithubAll3274416158 ns/op56112 B/op334 allocs/op
    BenchmarkGojiv2_GithubAll1402870518 ns/op352720 B/op4321 allocs/op
    BenchmarkGoJsonRest_GithubAll2976401507 ns/op134371 B/op2737 allocs/op
    BenchmarkGoRestful_GithubAll4102913158 ns/op910144 B/op2938 allocs/op
    BenchmarkGorillaMux_GithubAll3463384987 ns/op251650 B/op1994 allocs/op
    BenchmarkGowwwRouter_GithubAll10000143025 ns/op72144 B/op501 allocs/op
    BenchmarkHttpRouter_GithubAll5593821360 ns/op0 B/op0 allocs/op
    BenchmarkHttpTreeMux_GithubAll10000153944 ns/op65856 B/op671 allocs/op
    BenchmarkKocha_GithubAll10000106315 ns/op23304 B/op843 allocs/op
    BenchmarkLARS_GithubAll4777925084 ns/op0 B/op0 allocs/op
    BenchmarkMacaron_GithubAll3266371907 ns/op149409 B/op1624 allocs/op
    BenchmarkMartini_GithubAll3313444706 ns/op226551 B/op2325 allocs/op
    BenchmarkPat_GithubAll2734381818 ns/op1483152 B/op26963 allocs/op
    BenchmarkPossum_GithubAll10000164367 ns/op84448 B/op609 allocs/op
    BenchmarkR2router_GithubAll10000160220 ns/op77328 B/op979 allocs/op
    BenchmarkRivet_GithubAll1462582453 ns/op16272 B/op167 allocs/op
    BenchmarkTango_GithubAll6255279611 ns/op63826 B/op1618 allocs/op
    BenchmarkTigerTonic_GithubAll2008687874 ns/op193856 B/op4474 allocs/op
    BenchmarkTraffic_GithubAll3553478508 ns/op820744 B/op14114 allocs/op
    BenchmarkVulcan_GithubAll6885193333 ns/op19894 B/op609 allocs/op
    • (1): Total Repetitions achieved in constant time, higher means more confident result
    • (2): Single Repetition Duration (ns/op), lower is better
    • (3): Heap Memory (B/op), lower is better
    • (4): Average Allocations per Repetition (allocs/op), lower is better

    Middleware

    You can find many useful Gin middlewares at gin-contrib and gin-gonic/contrib.

    Uses

    Here are some awesome projects that are using the Gin web framework.

    • gorush: A push notification server.
    • fnproject: A container native, cloud agnostic serverless platform.
    • photoprism: Personal photo management powered by Google TensorFlow.
    • lura: Ultra performant API Gateway with middleware.
    • picfit: An image resizing server.
    • dkron: Distributed, fault tolerant job scheduling system.

    Contributing

    Gin is the work of hundreds of contributors. We appreciate your help!

    Please see CONTRIBUTING.md for details on submitting patches and the contribution workflow.

    Discover Repositories

    Search across tracked repositories by name or description