Skip to content

How to use map type in generics ? #1711

@marsberrys

Description

@marsberrys

// @response 200 {object} res.Result[map[string]dashboard.DailyStatistics]

whene run swag init , it report error: "Error parsing type definition 'res.Result-map[string]dashboard_DailyStatistics': data: cannot find type definition: map[string]dashboard.DailyStatistics"

type Result[T any] struct {
Code int64 json:"code" // 返回码,正常返回 0;错误时返回对应错误码
ErrorMsg string json:"err_msg,omitempty" // 错误信息,错误时返回
Data T json:"data,omitempty" // 返回内容,正常时返回
RequestID string json:"request_id" // 请求跟踪 ID (Trace ID)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions