go 语言--gin 框架安装
安装命令
go get -u github.com/gin-gonic/gin
如果慢设置国内镜像
# 七牛镜像
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
# 阿里镜像
go env -w GO111MODULE=on
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
简单测试
package main
import "github.com/gin-gonic/gin"
func main() {
// 添加gin框架3步
// 1.初始化路由
route := gin.Default()
// 2.路由匹配
route.GET("/", func(context *gin.Context) {
context.Writer.WriteString("hello")
})
// 3.启动运行
route.Run(":8080")
}
Comments
Post a Comment