安装
-
下载安装gin
go get -u github.com/gin-gonic/gin
-
将gin库导入到代码中(如果需要使用
http.StatusOk
之类的常量还需要引入net/http
包)import "github.com/gin-gonic/gin"
-
运行测试
package main import "github.com/gin-gonic/gin" func main() { engine := gin.Default() engine.GET("/ping", func(context *gin.Context) { //返回JSON数据 context.JSON(200,gin.H{ "message":"pong", }) }) engine.Run() //默认运行在8080端口 }
//TODO
标签:engine,github,框架,gin,Gin,com,gonic From: https://www.cnblogs.com/9men/p/16746463.html