Gin
Gin 

github的地址在这里。

要安装 Gin 包,您需要先安装 Go 并设置您的 Go 工作区。

go install github.com/gin-gonic/gin@latest

在代码的目录下执行:

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

在您的代码中导入它:

import "github.com/gin-gonic/gin"
net/httphttp.StatusOK.
import "net/http"

以下是快速开始的全部代码:

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")
}

执行完以后:

[GIN-debug] GET    /ping                     --> main.main.func1 (3 handlers)
[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.
[GIN-debug] Environment variable PORT is undefined. Using port :8080 by default
[GIN-debug] Listening and serving HTTP on :8080

在浏览器中,访问链接,出现如下的代码。