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

gin框架中文文档

https://www.kancloud.cn/shuangdeyu/gin_book/949411

Comments

Popular posts from this blog

什么是smart原则

【Protocol Buffer】简介和安装

Novice running training plan: How to run 5 kilometers in 30 minutes?