diff --git a/op_array/util.go b/op_array/util.go index 9d229a0..29854f6 100644 --- a/op_array/util.go +++ b/op_array/util.go @@ -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 +}