From fdbab363d681cfdd75ebf9dc9d2ced8a74711fe6 Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Thu, 5 Jan 2017 14:53:41 -0800 Subject: [PATCH] Standardize line breaks on method signatures I am standardizing the method signatures on long method names or methods that accept predicateFns for prettier "go doc" or "godoc" output based on following rules: 1. first parameter on the same line as method name 2. rest of the parameters are each on a new line 3. return type is at the same line as the last parameter Signed-off-by: Ahmet Alp Balkan --- aggregate.go | 23 ++++++++++------------- doc.go | 10 ++++------ except.go | 7 ++++--- groupby.go | 10 ++++------ groupjoin.go | 11 ++++++----- intersect.go | 9 ++++----- join.go | 9 +++------ orderby.go | 9 +++------ result.go | 9 ++++----- selectmany.go | 12 ++++++------ zip.go | 9 ++++----- 11 files changed, 52 insertions(+), 66 deletions(-) diff --git a/aggregate.go b/aggregate.go index 4ed8930..bb1975d 100644 --- a/aggregate.go +++ b/aggregate.go @@ -10,8 +10,7 @@ package linq // result of f() replaces the previous aggregated value. // // Aggregate returns the final result of f(). -func (q Query) Aggregate( - f func(interface{}, interface{}) interface{}) interface{} { +func (q Query) Aggregate(f func(interface{}, interface{}) interface{}) interface{} { next := q.Iterate() result, any := next() @@ -32,7 +31,6 @@ func (q Query) Aggregate( // // NOTE: Aggregate has better performance than AggregateT. func (q Query) AggregateT(f interface{}) interface{} { - fGenericFunc, err := newGenericFunc( "AggregateT", "f", f, simpleParamValidator(newElemTypeSlice(new(genericType), new(genericType)), newElemTypeSlice(new(genericType))), @@ -59,10 +57,8 @@ func (q Query) AggregateT(f interface{}) interface{} { // The result of f() replaces the previous aggregated value. // // Aggregate returns the final result of f(). -func (q Query) AggregateWithSeed( - seed interface{}, - f func(interface{}, interface{}) interface{}, -) interface{} { +func (q Query) AggregateWithSeed(seed interface{}, + f func(interface{}, interface{}) interface{}) interface{} { next := q.Iterate() result := seed @@ -80,7 +76,8 @@ func (q Query) AggregateWithSeed( // // NOTE: AggregateWithSeed has better performance than // AggregateWithSeedT. -func (q Query) AggregateWithSeedT(seed interface{}, f interface{}) interface{} { +func (q Query) AggregateWithSeedT(seed interface{}, + f interface{}) interface{} { fGenericFunc, err := newGenericFunc( "AggregateWithSeed", "f", f, simpleParamValidator(newElemTypeSlice(new(genericType), new(genericType)), newElemTypeSlice(new(genericType))), @@ -109,11 +106,9 @@ func (q Query) AggregateWithSeedT(seed interface{}, f interface{}) interface{} { // // The final result of func is passed to resultSelector to obtain the final // result of Aggregate. -func (q Query) AggregateWithSeedBy( - seed interface{}, +func (q Query) AggregateWithSeedBy(seed interface{}, f func(interface{}, interface{}) interface{}, - resultSelector func(interface{}) interface{}, -) interface{} { + resultSelector func(interface{}) interface{}) interface{} { next := q.Iterate() result := seed @@ -132,7 +127,9 @@ func (q Query) AggregateWithSeedBy( // // NOTE: AggregateWithSeedBy has better performance than // AggregateWithSeedByT. -func (q Query) AggregateWithSeedByT(seed interface{}, f interface{}, resultSelectorFn interface{}) interface{} { +func (q Query) AggregateWithSeedByT(seed interface{}, + f interface{}, + resultSelectorFn interface{}) interface{} { fGenericFunc, err := newGenericFunc( "AggregateWithSeedByT", "f", f, simpleParamValidator(newElemTypeSlice(new(genericType), new(genericType)), newElemTypeSlice(new(genericType))), diff --git a/doc.go b/doc.go index c2fe778..c89c4fe 100644 --- a/doc.go +++ b/doc.go @@ -1,8 +1,6 @@ -// Package linq provides methods for querying and manipulating -// slices, arrays, maps, strings, channels and collections. -// -// -// Authors: Alexander Kalankhodzhaev (kalan), Ahmet Alp Balkan, Cleiton Marques Souza -// +// Package linq provides methods for querying and manipulating slices, arrays, +// maps, strings, channels and collections. // +// Authors: Alexander Kalankhodzhaev (kalan), Ahmet Alp Balkan, Cleiton Marques +// Souza. package linq diff --git a/except.go b/except.go index 8f881c2..d146992 100644 --- a/except.go +++ b/except.go @@ -29,8 +29,8 @@ 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 { +func (q Query) ExceptBy(q2 Query, + selector func(interface{}) interface{}) Query { return Query{ Iterate: func() Iterator { next := q.Iterate() @@ -61,7 +61,8 @@ func (q Query) ExceptBy( // - selectorFn is of type "func(TSource) TSource" // // NOTE: ExceptBy has better performance than ExceptByT. -func (q Query) ExceptByT(q2 Query, selectorFn interface{}) Query { +func (q Query) ExceptByT(q2 Query, + selectorFn interface{}) Query { selectorGenericFunc, err := newGenericFunc( "ExceptByT", "selectorFn", selectorFn, simpleParamValidator(newElemTypeSlice(new(genericType)), newElemTypeSlice(new(genericType))), diff --git a/groupby.go b/groupby.go index 376ec10..face510 100644 --- a/groupby.go +++ b/groupby.go @@ -9,11 +9,8 @@ type Group struct { // GroupBy method groups the elements of a collection according to a specified // key selector function and projects the elements for each group by using a // specified function. -func (q Query) GroupBy( - keySelector func(interface{}) interface{}, - elementSelector func(interface{}) interface{}, -) Query { - +func (q Query) GroupBy(keySelector func(interface{}) interface{}, + elementSelector func(interface{}) interface{}) Query { return Query{ func() Iterator { next := q.Iterate() @@ -53,7 +50,8 @@ func (q Query) GroupBy( // - elementSelectorFn is of type "func(TSource) TElement" // // NOTE: GroupBy has better performance than GroupByT. -func (q Query) GroupByT(keySelectorFn interface{}, elementSelectorFn interface{}) Query { +func (q Query) GroupByT(keySelectorFn interface{}, + elementSelectorFn interface{}) Query { keySelectorGenericFunc, err := newGenericFunc( "GroupByT", "keySelectorFn", keySelectorFn, simpleParamValidator(newElemTypeSlice(new(genericType)), newElemTypeSlice(new(genericType))), diff --git a/groupjoin.go b/groupjoin.go index 276923b..f9f8144 100644 --- a/groupjoin.go +++ b/groupjoin.go @@ -18,12 +18,10 @@ import "reflect" // // GroupJoin preserves the order of the elements of outer, and for each element // of outer, the order of the matching elements from inner. -func (q Query) GroupJoin( - inner Query, +func (q Query) GroupJoin(inner Query, outerKeySelector func(interface{}) interface{}, innerKeySelector func(interface{}) interface{}, - resultSelector func(outer interface{}, inners []interface{}) interface{}, -) Query { + resultSelector func(outer interface{}, inners []interface{}) interface{}) Query { return Query{ Iterate: func() Iterator { @@ -61,7 +59,10 @@ func (q Query) GroupJoin( // - resultSelectorFn: is of type "func(TOuter, inners []TInner) TResult" // // NOTE: GroupJoin has better performance than GroupJoinT. -func (q Query) GroupJoinT(inner Query, outerKeySelectorFn interface{}, innerKeySelectorFn interface{}, resultSelectorFn interface{}) Query { +func (q Query) GroupJoinT(inner Query, + outerKeySelectorFn interface{}, + innerKeySelectorFn interface{}, + resultSelectorFn interface{}) Query { outerKeySelectorGenericFunc, err := newGenericFunc( "GroupJoinT", "outerKeySelectorFn", outerKeySelectorFn, simpleParamValidator(newElemTypeSlice(new(genericType)), newElemTypeSlice(new(genericType))), diff --git a/intersect.go b/intersect.go index b61eb7d..511ed3b 100644 --- a/intersect.go +++ b/intersect.go @@ -35,10 +35,8 @@ func (q Query) Intersect(q2 Query) Query { // other elements. // // IntersectBy invokes a transform function on each element of both collections. -func (q Query) IntersectBy( - q2 Query, - selector func(interface{}) interface{}, -) Query { +func (q Query) IntersectBy(q2 Query, + selector func(interface{}) interface{}) Query { return Query{ Iterate: func() Iterator { @@ -71,7 +69,8 @@ func (q Query) IntersectBy( // - selectorFn is of type "func(TSource) TSource" // // NOTE: IntersectBy has better performance than IntersectByT. -func (q Query) IntersectByT(q2 Query, selectorFn interface{}) Query { +func (q Query) IntersectByT(q2 Query, + selectorFn interface{}) Query { selectorGenericFunc, err := newGenericFunc( "IntersectByT", "selectorFn", selectorFn, simpleParamValidator(newElemTypeSlice(new(genericType)), newElemTypeSlice(new(genericType))), diff --git a/join.go b/join.go index c1e86bc..68211a2 100644 --- a/join.go +++ b/join.go @@ -10,12 +10,10 @@ package linq // // Join preserves the order of the elements of outer collection, and for each of // these elements, the order of the matching elements of inner. -func (q Query) Join( - inner Query, +func (q Query) Join(inner Query, outerKeySelector func(interface{}) interface{}, innerKeySelector func(interface{}) interface{}, - resultSelector func(outer interface{}, inner interface{}) interface{}, -) Query { + resultSelector func(outer interface{}, inner interface{}) interface{}) Query { return Query{ Iterate: func() Iterator { @@ -65,8 +63,7 @@ func (q Query) Join( func (q Query) JoinT(inner Query, outerKeySelectorFn interface{}, innerKeySelectorFn interface{}, - resultSelectorFn interface{}, -) Query { + resultSelectorFn interface{}) Query { outerKeySelectorGenericFunc, err := newGenericFunc( "JoinT", "outerKeySelectorFn", outerKeySelectorFn, simpleParamValidator(newElemTypeSlice(new(genericType)), newElemTypeSlice(new(genericType))), diff --git a/orderby.go b/orderby.go index 8feb50e..110559d 100644 --- a/orderby.go +++ b/orderby.go @@ -18,8 +18,7 @@ type OrderedQuery struct { // OrderBy sorts the elements of a collection in ascending order. Elements are // sorted according to a key. -func (q Query) OrderBy( - selector func(interface{}) interface{}) OrderedQuery { +func (q Query) OrderBy(selector func(interface{}) interface{}) OrderedQuery { return OrderedQuery{ orders: []order{{selector: selector}}, original: q, @@ -66,8 +65,7 @@ func (q Query) OrderByT(selectorFn interface{}) OrderedQuery { // OrderByDescending sorts the elements of a collection in descending order. // Elements are sorted according to a key. -func (q Query) OrderByDescending( - selector func(interface{}) interface{}) OrderedQuery { +func (q Query) OrderByDescending(selector func(interface{}) interface{}) OrderedQuery { return OrderedQuery{ orders: []order{{selector: selector, desc: true}}, original: q, @@ -160,8 +158,7 @@ func (oq OrderedQuery) ThenByT(selectorFn interface{}) OrderedQuery { // ThenByDescending performs a subsequent ordering of the elements in a // collection in descending order. This method enables you to specify multiple // sort criteria by applying any number of ThenBy or ThenByDescending methods. -func (oq OrderedQuery) ThenByDescending( - selector func(interface{}) interface{}) OrderedQuery { +func (oq OrderedQuery) ThenByDescending(selector func(interface{}) interface{}) OrderedQuery { return OrderedQuery{ orders: append(oq.orders, order{selector: selector, desc: true}), original: oq.original, diff --git a/result.go b/result.go index f75ed8f..844d2b0 100644 --- a/result.go +++ b/result.go @@ -493,11 +493,9 @@ func (q Query) ToMap(result interface{}) { // element of the collection to generate key and value for the map. Generated // key and value types must be assignable to the map's key and value types. // ToMapBy doesn't empty the result map before populating it. -func (q Query) ToMapBy( - result interface{}, +func (q Query) ToMapBy(result interface{}, keySelector func(interface{}) interface{}, - valueSelector func(interface{}) interface{}, -) { + valueSelector func(interface{}) interface{}) { res := reflect.ValueOf(result) m := reflect.Indirect(res) next := q.Iterate() @@ -518,7 +516,8 @@ func (q Query) ToMapBy( // - valueSelectorFn is of type "func(TSource)TValue" // // NOTE: ToMapBy has better performance than ToMapByT. -func (q Query) ToMapByT(result interface{}, keySelectorFn interface{}, valueSelectorFn interface{}) { +func (q Query) ToMapByT(result interface{}, + keySelectorFn interface{}, valueSelectorFn interface{}) { keySelectorGenericFunc, err := newGenericFunc( "ToMapByT", "keySelectorFn", keySelectorFn, simpleParamValidator(newElemTypeSlice(new(genericType)), newElemTypeSlice(new(genericType))), diff --git a/selectmany.go b/selectmany.go index 0f08623..74fa671 100644 --- a/selectmany.go +++ b/selectmany.go @@ -120,10 +120,8 @@ func (q Query) SelectManyIndexedT(selectorFn interface{}) Query { // SelectManyBy projects each element of a collection to a Query, iterates and // flattens the resulting collection into one collection, and invokes a result // selector function on each element therein. -func (q Query) SelectManyBy( - selector func(interface{}) Query, - resultSelector func(interface{}, interface{}) interface{}, -) Query { +func (q Query) SelectManyBy(selector func(interface{}) Query, + resultSelector func(interface{}, interface{}) interface{}) Query { return Query{ Iterate: func() Iterator { @@ -161,7 +159,8 @@ func (q Query) SelectManyBy( // - resultSelectorFn is of type "func(TSource,TCollection)TResult" // // NOTE: SelectManyBy has better performance than SelectManyByT. -func (q Query) SelectManyByT(selectorFn interface{}, resultSelectorFn interface{}) Query { +func (q Query) SelectManyByT(selectorFn interface{}, + resultSelectorFn interface{}) Query { selectorGenericFunc, err := newGenericFunc( "SelectManyByT", "selectorFn", selectorFn, @@ -236,7 +235,8 @@ func (q Query) SelectManyByIndexed(selector func(int, interface{}) Query, // // NOTE: SelectManyByIndexed has better performance than // SelectManyByIndexedT. -func (q Query) SelectManyByIndexedT(selectorFn interface{}, resultSelectorFn interface{}) Query { +func (q Query) SelectManyByIndexedT(selectorFn interface{}, + resultSelectorFn interface{}) Query { selectorGenericFunc, err := newGenericFunc( "SelectManyByIndexedT", "selectorFn", selectorFn, simpleParamValidator(newElemTypeSlice(new(int), new(genericType)), newElemTypeSlice(new(Query))), diff --git a/zip.go b/zip.go index 252c045..da3dcd3 100644 --- a/zip.go +++ b/zip.go @@ -10,10 +10,8 @@ package linq // combines elements until it reaches the end of one of the collections. For // example, if one collection has three elements and the other one has four, the // result collection has only three elements. -func (q Query) Zip( - q2 Query, - resultSelector func(interface{}, interface{}) interface{}, -) Query { +func (q Query) Zip(q2 Query, + resultSelector func(interface{}, interface{}) interface{}) Query { return Query{ Iterate: func() Iterator { @@ -39,7 +37,8 @@ func (q Query) Zip( // - resultSelectorFn is of type "func(TFirst,TSecond)TResult" // // NOTE: Zip has better performance than ZipT. -func (q Query) ZipT(q2 Query, resultSelectorFn interface{}) Query { +func (q Query) ZipT(q2 Query, + resultSelectorFn interface{}) Query { resultSelectorGenericFunc, err := newGenericFunc( "ZipT", "resultSelectorFn", resultSelectorFn, simpleParamValidator(newElemTypeSlice(new(genericType), new(genericType)), newElemTypeSlice(new(genericType))),