feat: 过滤列表数据方法

This commit is contained in:
zhangdeman committed 2025-11-25 11:55:58 +08:00
1 parent d3eb702c74
commit 2cbffbd883
1 file changed
+11
+11
View File
@@ -26,3 +26,14 @@ func ExtractField[FieldValue any, Value any](dataList []Value, fieldValue func(i
}
return res
}
// Filter 过滤列表数据
func Filter[Value any](dataList []Value, filterValue func(item Value) bool) []Value {
res := make([]Value, 0)
for _, item := range dataList {
if filterValue(item) {
res = append(res, item)
}
}
return res
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.