feat: 过滤列表数据方法

This commit is contained in:
2025-11-25 11:55:58 +08:00
parent d3eb702c74
commit 2cbffbd883

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
}