feat(Go-Tool):2020/12/14:添加validator.v8源码解析和使用示例

This commit is contained in:
Huangzj
2020-12-14 15:15:58 +08:00
parent 23d7d6e226
commit fa31b23cca
51 changed files with 4619 additions and 1662 deletions
+9 -29
View File
@@ -1,7 +1,8 @@
package linq
// Except produces the set difference of two sequences. The set difference is
// the members of the first sequence that don't appear in the second sequence.
// Except produces the set difference of two sequences.
// The set difference is the members of the first sequence
// that don't appear in the second sequence.
func (q Query) Except(q2 Query) Query {
return Query{
Iterate: func() Iterator {
@@ -26,11 +27,12 @@ func (q Query) Except(q2 Query) Query {
}
}
// ExceptBy invokes a transform function on each element of a collection and
// produces the set difference of two sequences. The set difference is the
// members of the first sequence that don't appear in the second sequence.
func (q Query) ExceptBy(q2 Query,
selector func(interface{}) interface{}) Query {
// ExceptBy invokes a transform function on each element of a collection
// and produces the set difference of two sequences.
// The set difference is the members of the first sequence
// that don't appear in the second sequence.
func (q Query) ExceptBy(
q2 Query, selector func(interface{}) interface{}) Query {
return Query{
Iterate: func() Iterator {
next := q.Iterate()
@@ -55,25 +57,3 @@ func (q Query) ExceptBy(q2 Query,
},
}
}
// ExceptByT is the typed version of ExceptBy.
//
// - selectorFn is of type "func(TSource) TSource"
//
// NOTE: ExceptBy has better performance than ExceptByT.
func (q Query) ExceptByT(q2 Query,
selectorFn interface{}) Query {
selectorGenericFunc, err := newGenericFunc(
"ExceptByT", "selectorFn", selectorFn,
simpleParamValidator(newElemTypeSlice(new(genericType)), newElemTypeSlice(new(genericType))),
)
if err != nil {
panic(err)
}
selectorFunc := func(item interface{}) interface{} {
return selectorGenericFunc.Call(item)
}
return q.ExceptBy(q2, selectorFunc)
}