ubuntu Command swager not found

一个go项目迁移后,某天swagger页面提示如下错误:

Errors
Hide
Resolver errorCannot read properties of undefined (reading '1')

回忆一下好像最近改了一些接口,于是想用swag init来重新生成文档,但是提示我 ==Command 'swag' not found==。迁移后swag组件没装。按官网

go get -u github.com/swaggo/swag/cmd/swag,很顺利安装后,再次运行swag,还是提示上述错误。后来搜索很久才知道要到以下目录build一下

root@serv111:~/go/pkg/mod/github.com/swaggo/swag@v1.16.2/cmd/swag# go build -x -o swag main.go

最后运行swag init,根据对应报错提示,处理完就可以了!

评论已关闭