官网地址:
https://github.com/gin-gonic/gin
准备:
1、在任意路径下(不要有中文)创建api.go.com/live
2、cd到api.go.com/live
go mod init live.go.com
#其实这里叫 go mod init xxx 都行
3、然后执行:
go get -u github.com/gin-gonic/gin
等下载完成,用编辑器打开live
目录
简单示例
创建main.go
package main
import "github.com/gin-gonic/gin"
func main() {
router := gin.Default()
router.GET(string("/"), func(context *gin.Context) {
context.JSON(200, gin.H{"message": "pong"})
})
router.Run() //默认启动的是8080端口
}
运行