Use of Gin Framework

Enter the gopath directory and create gin_test_project

# Enter gopath and build gin_test_project
cd /Users/edz/go/src/gin_test_project
go mod init #initialize go mod
# Download gin package
go get -v github.com/gin-gonic/gin@v1.4

2.gin minimum unit

package main
import "github.com/gin-gonic/gin"
func main() {
    r := gin.Default()
    r.GET("/ping", func(context *gin.Context) {
        context.JSON(200, gin.H{
            "message": "pong",
        })
    })
    r.Run() //8080
}
#transport go
go run main.go
#editing and editing
  go build main.go && ./main

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish