我正在使用基于語法的swaggo生成API文檔。godoc源文件夾和文件|-post|--controller.go|--response.go對于此定義:controller.gopackage post...// Index godoc// @Summary Index Post// @Success 200 {array} []*Response// @Router /v1/posts [get]func Index(ctx *gin.Context) { ...}已在另一個文件中定義了 ,但包相同。Responseresponse.gopackage post// Response is post response bodytype Response struct { ID int64 `json:"id"` Name string `json:"name"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"`}但是當運行以生成swagger文檔時,它說:swag init2021/01/29 09:39:56 Generate swagger docs....2021/01/29 09:39:56 Generate general API Info, search dir:./2021/01/29 09:39:56 ParseComment error in file application/post/controller.go :cannot find type definition:當我將結構移動到 時,它起作用。Responsecontroller.go如何用godoc或swaggo進口它?
如何在另一個文件中使用帶有 swaggo 的類型定義?
慕的地8271018
2022-08-01 18:54:16