swaggo / gin-swagger

gin middleware to automatically generate RESTful API documentation with Swagger 2.0.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to reference Struct Outside main.go folder?

sithu-go opened this issue · comments

i have folder structure like this

├── cmd
│   ├── main.go
│   └── handler
│         └──example_controller.go
├── dto
│    └──request.go
├── go.mod
└── go.sum

From example_controller.go, I want to reference a struct from dto.request.go
How can i do that.

// Create System Config
// @summary Create System Config
// @description Create System Config
// @tags System Config
// @id createSystemConfig
// @accept json
// @produce json
// @param SystemConfig body dto.ReqCSSystemConfig true "created system config to be returned"
// @response 200 {object} ResponseObject "OK"
// @Router /sytem-configs/add [post]

In the same folder structure it can reference, but how can i do that outside of main.go folder?

2022/10/11 13:43:00 Generate swagger docs....
2022/10/11 13:43:00 Generate general API Info, search dir:./
2022/10/11 13:43:00 Generating handler.ResponseObject
2022/10/11 13:43:00 ParseComment error in file /home/sithu/huyi/second/douyou_golang/cmd/back/handler/systemconfig_controller.go :cannot find type definition: dto.ReqCSSystemConfig