Go——Swagger API文档访问500

Go——Swagger API文档访问500

解决方案

bug 总结

swag init 生成了 docs.go,但 Go 编译器不会自动把它编进二进制;
必须显式 import _ “项目/docs”,否则 Swagger 处理器找不到文档数据,就空 500。

swag init
import(_"github.com/项目/docs"// 必须导入生成的 docs 包)