最近在研究Go的Gin框架,本文简单记录怎么整合Swagger。
版本信息:
gin v1.6.3
swag v1.6.7
创建一个Go工程!
首先下载安装Gin以及Swagger依赖包:
go get -u github.com/gin-gonic/gingo get -u github.com/swaggo/swag/cmd/swa
若报以下错:
go get github.com/gin-gonic/gin: module github.com/gin-gonic/gin: Get "https://proxy.golang.org/github.com/gin-gonic/gin/@v/list": dial tcp 172.217.160.113:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
则是国内无法访问到Go官方网站https://golang.org/
可替换成国内七牛云的镜像(前提是环境参数set GO111MODULE=on,不然需先执行go env -w GO111MODULE=on):