Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use map type in generics ? #1711

Closed
marsberrys opened this issue Nov 28, 2023 · 0 comments
Closed

How to use map type in generics ? #1711

marsberrys opened this issue Nov 28, 2023 · 0 comments
Labels

Comments

@marsberrys
Copy link

// @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)
}

@marsberrys marsberrys changed the title why can not use map type in generics ? Can not use map type in generics ? Dec 7, 2023
@marsberrys marsberrys changed the title Can not use map type in generics ? How to use map type in generics ? Dec 7, 2023
@sdghchj sdghchj closed this as completed Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants