Skip to content

Go with Gin

High-performance Go web framework.

Overview

Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance.

Features

  • Fast performance
  • Middleware support
  • JSON validation
  • Route grouping
  • Error management
  • Built-in rendering

Getting Started

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

Basic Example

go
package main

import (
    "github.com/gin-gonic/gin"
    "net/http"
)

func main() {
    r := gin.Default()
    
    r.GET("/", func(c *gin.Context) {
        c.JSON(http.StatusOK, gin.H{
            "message": "Hello, Gin!",
        })
    })
    
    r.GET("/users/:id", func(c *gin.Context) {
        id := c.Param("id")
        c.JSON(http.StatusOK, gin.H{
            "user_id": id,
        })
    })
    
    r.Run() // listen and serve on 0.0.0.0:8080
}

PAPER-CODE Integration

PAPER-CODE provides:

  • Go project templates
  • Gin framework setup
  • Database integrations
  • Testing configurations

Resources