在windows上安装swaggo(swagger&x2B;gin)

在windows上安装swaggo(swagger&x2B;gin),windows,go,swagger,go-gin,Windows,Go,Swagger,Go Gin,我正在尝试在windows上设置gin gonic的swagger。 swaggo的文档说明我应该运行: go get -u github.com/swaggo/swag/cmd/swag 安装后,我应该能够从我的项目根目录中运行swag init,其中我有main.go,但cmdlet声明如下: swag : The term 'swag' is not recognized as the name of a cmdlet, function, script file, or operabl

我正在尝试在windows上设置gin gonic的swagger。 swaggo的文档说明我应该运行:

go get -u github.com/swaggo/swag/cmd/swag
安装后,我应该能够从我的项目根目录中运行
swag init
,其中我有
main.go
,但cmdlet声明如下:

swag : The term 'swag' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is    correct and try again.
At line:1 char:1
+ swag
+ ~~~~
+ CategoryInfo          : ObjectNotFound: (swag:String) [],  CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
如何将swag添加到路径,或者如何从这里开始

另外,我遵循了


更新:所以我在另一台电脑上进行了Go的干净安装,接着是
Go get-u github.com/swaggo/swag/cmd/swag
swag
在bat的右边运行。之前我学习了教程,我可能不小心弄乱了我的
$GOPATH
在原始PC上。

将$GOPATH/bin添加到PATH中,例如:


导出路径=$PATH:/Users/../go/bin

首先清除缓存

-go clean --modcache
如何在go中安装swagger

-https://libraries.io/go/github.com%2Fswaggo%2Fhttp-swagger
-转到您的文件路径,让他们安装以下软件包 1-
go-get-github.com/swaggo/http-swagger
2-使用以下工具下载Go的Swag:

-go get github.com/swaggo/swag/cmd/swag
- go get -u github.com/swaggo/http-swagger
3-在包含main.Go文件的Go项目根文件夹中运行Swag,Swag将解析注释并生成所需文件(docs文件夹和docs/doc.Go)

4.使用以下工具下载http swagger:

-go get github.com/swaggo/swag/cmd/swag
- go get -u github.com/swaggo/http-swagger
5-运行它,并通过浏览器
-http://localhost:1323/swagger/index.html
,您可以看到Swagger 2.0 Api文档

并了解您正在处理的路径类型

-go env

然后查找
GOPATH=
在那里您将看到您的路径

有关更多信息,请转到此处
https://github.com/swaggo/http-swagger
杜松子酒招摇过市时也要用到这个
https://github.com/swaggo/gin-swagger