本文主要是介绍Go的Gin框架整合Swagger,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
最近在研究Go的Gin框架,本文简单记录怎么整合Swagger。
版本信息:
gin v1.6.3
swag v1.6.7
首先下载安装Gin以及Swagger依赖包:
go get -u github.com/gin-gonic/gin
go get -u github.com/swaggo/swag/cmd/swag
若报以下错:
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.
则是国内无法访问到https://golang.org/
可替换成国内七牛云的镜像(前提是环境参数set GO111MODULE=on,不然需先执行go env -w GO111MODULE=on):
go env -w GOPROXY=https://goproxy.cn,direct
之后再次下载就成功了
这篇关于Go的Gin框架整合Swagger的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!