【One by one系列】一步步学习Golang web框架Gin
2021-04-26 14:28
标签:iter require net web框架 field yam 执行 oca mys 就可以看到在src\github.com\carfield 生成了go.mod文件 ps:由于众所周知的原因,大概率是下不动,所以请修改代理 再次打开go.mod文件 【One by one系列】一步步学习Golang web框架Gin 标签:iter require net web框架 field yam 执行 oca mys 原文地址:https://www.cnblogs.com/RandyField/p/12220798.html一步步学习Golang web框架Gin
建立项目
go mod 管理依赖
cd $gopath\src\github.com\carfield
go mod init
module github.com/carfield
go 1.13
下载gin包
go get -u github.com/gin-gonic/gin
修改代理
go env -w GOPROXY=https://goproxy.cn,direct
再次执行
go get -u github.com/gin-gonic/gin
module github.com/carfield
go 1.13
require (
github.com/gin-gonic/gin v1.5.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-sql-driver/mysql v1.5.0 // indirect
github.com/json-iterator/go v1.1.9 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.11 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
golang.org/x/sys v0.0.0-20200117145432-59e60aa80a0c // indirect
gopkg.in/go-playground/validator.v9 v9.31.0 // indirect
gopkg.in/yaml.v2 v2.2.7 // indirect
)
module
定义包名require
用来定义依赖包及版本indirect
表示简介引用快速开始
import "github.com/gin-gonic/gin"
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "hello,go-gin wholeheartedly at your service",
})
})
r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}
上一篇:js 词法分析,词法作用域
下一篇:JS——定时弹出图片
文章标题:【One by one系列】一步步学习Golang web框架Gin
文章链接:http://soscw.com/index.php/essay/79824.html