首页 > 解决方案 > 在 Windows 上安装 swagger (swagger + gin)

问题描述

我正在尝试在 Windows 上为 gin-gonic 设置招摇。swago 的文档说明我应该运行:

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

如何将赃物添加到 PATH 或者我应该如何从这里开始?

Ps,我从这里关注了文档

更新:所以我在另一台 PC 上进行了 Go 的全新安装,然后go get -u github.com/swaggo/swag/cmd/swag直接swag运行。早些时候我遵循了本教程,我可能不小心弄乱了我$GOPATH原来的 PC。

标签: windowsgoswaggergo-gin

解决方案


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

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


推荐阅读