diff --git a/actor.go b/actor.go index b4815d4..cee1e82 100644 --- a/actor.go +++ b/actor.go @@ -5,9 +5,7 @@ import ( "time" ) -var ( - ErrActorAskTimeout = fmt.Errorf("ErrActorAskTimeout") -) +var ErrActorAskTimeout = fmt.Errorf("ErrActorAskTimeout") // ActorHandle A target could send messages type ActorHandle[T any] interface { diff --git a/cor.go b/cor.go index 6416c2c..77a4368 100644 --- a/cor.go +++ b/cor.go @@ -148,6 +148,7 @@ func (corSelf *CorDef[T]) YieldFrom(target *CorDef[T], in T) T { return result } + func (corSelf *CorDef[T]) receive(cor *CorDef[T], in T) { corSelf.doCloseSafe(func() { if corSelf.opCh != nil { @@ -184,6 +185,7 @@ func (corSelf *CorDef[T]) IsDone() bool { func (corSelf *CorDef[T]) IsStarted() bool { return corSelf.isStarted.Get() } + func (corSelf *CorDef[T]) close() { corSelf.isClosed.Set(true) @@ -196,6 +198,7 @@ func (corSelf *CorDef[T]) close() { } corSelf.closedM.Unlock() } + func (corSelf *CorDef[T]) doCloseSafe(fn func()) { if corSelf.IsDone() { return diff --git a/cor_test.go b/cor_test.go index bc0f568..d094fa4 100644 --- a/cor_test.go +++ b/cor_test.go @@ -17,7 +17,7 @@ func logMessage(args ...interface{}) { func TestCorYield(t *testing.T) { var expectedInt int - var actualInt = 0 + actualInt := 0 var testee *CorDef[interface{}] var wg sync.WaitGroup diff --git a/fp.go b/fp.go index 0369af8..76cff95 100644 --- a/fp.go +++ b/fp.go @@ -91,7 +91,6 @@ func ComposeInterface(fnList ...func(...interface{}) []interface{}) func(...inte // Pipe Pipe the functions from left to right func Pipe[T any](fnList ...func(...T) []T) func(...T) []T { return func(s ...T) []T { - lastIndex := len(fnList) - 1 f := fnList[lastIndex] nextFnList := fnList[:lastIndex] @@ -131,7 +130,6 @@ func MapIndexed[T any, R any](fn func(T, int) R, values ...T) []R { // Reduce Reduce the values from left to right(func(memo,val), starting value, slice) func Reduce[T any, R any](fn ReducerFunctor[T, R], memo R, input ...T) R { - for i := 0; i < len(input); i++ { memo = fn(memo, input[i]) } @@ -141,7 +139,6 @@ func Reduce[T any, R any](fn ReducerFunctor[T, R], memo R, input ...T) R { // ReduceIndexed Reduce the values from left to right(func(memo,val,index), starting value, slice) func ReduceIndexed[T any, R any](fn func(R, T, int) R, memo R, input ...T) R { - for i := 0; i < len(input); i++ { memo = fn(memo, input[i], i) } @@ -151,9 +148,9 @@ func ReduceIndexed[T any, R any](fn func(R, T, int) R, memo R, input ...T) R { // Filter Filter the values by the given predicate function (predicate func, slice) func Filter[T any](fn func(T, int) bool, input ...T) []T { - var list = make([]T, len(input)) + list := make([]T, len(input)) - var newLen = 0 + newLen := 0 for i := range input { if fn(input[i], i) { @@ -176,18 +173,18 @@ func Reject[T any](fn func(T, int) bool, input ...T) []T { // Concat Concat slices func Concat[T any](mine []T, slices ...[]T) []T { - var mineLen = len(mine) - var totalLen = mineLen + mineLen := len(mine) + totalLen := mineLen for _, slice := range slices { if slice == nil { continue } - var targetLen = len(slice) + targetLen := len(slice) totalLen += targetLen } - var newOne = make([]T, totalLen) + newOne := make([]T, totalLen) for i, item := range mine { newOne[i] = item @@ -199,8 +196,8 @@ func Concat[T any](mine []T, slices ...[]T) []T { continue } - var target = slice - var targetLen = len(target) + target := slice + targetLen := len(target) for j, item := range target { newOne[totalIndex+j] = item } @@ -970,7 +967,7 @@ func PMap[T any, R any](f TransformerFunctor[T, R], option *PMapOption, list ... return make([]R, 0) } - var worker = len(list) + worker := len(list) if option != nil { if option.FixedPool > 0 && option.FixedPool < worker { worker = option.FixedPool @@ -1354,7 +1351,6 @@ func UniqBy[T any, R comparable](identify TransformerFunctor[T, R], list ...T) [ // Flatten creates a new slice where one level of nested elements are unnested func Flatten[T any](list ...[]T) []T { - result := make([]T, 0) // for _, v := range list { @@ -1942,8 +1938,7 @@ type ProductType struct { } // NilTypeDef NilType implemented by Nil determinations -type NilTypeDef struct { -} +type NilTypeDef struct{} // Matches Check does it match the SumType func (typeSelf SumType) Matches(value ...interface{}) bool { diff --git a/fp_test.go b/fp_test.go index f7ee51a..36f3d01 100644 --- a/fp_test.go +++ b/fp_test.go @@ -32,15 +32,15 @@ func SortStringAscending(input ...interface{}) []interface{} { func TestCompose(t *testing.T) { var expectedinteger int - var fn01 = func(args ...int) []int { + fn01 := func(args ...int) []int { val := args[0] return SliceOf(val + 1) } - var fn02 = func(args ...int) []int { + fn02 := func(args ...int) []int { val := args[0] return SliceOf(val + 2) } - var fn03 = func(args ...int) []int { + fn03 := func(args ...int) []int { val := args[0] return SliceOf(val + 3) } @@ -68,7 +68,6 @@ func TestCompose(t *testing.T) { expectedinteger = 6 assert.Equal(t, expectedinteger, Pipe(fn01, fn02, fn03)((0))[0]) - } func TestFPFunctions(t *testing.T) { @@ -84,7 +83,6 @@ func TestFPFunctions(t *testing.T) { var actualMap map[int]int fib := func(n int) int { - result, _ := Trampoline(func(input ...int) ([]int, bool, error) { n := input[0] a := input[1] @@ -287,9 +285,9 @@ func TestCurry(t *testing.T) { } func TestCompType(t *testing.T) { - var compTypeA = DefProduct(reflect.Int, reflect.String) - var compTypeB = DefProduct(reflect.String) - var myType = DefSum(NilType, compTypeA, compTypeB) + compTypeA := DefProduct(reflect.Int, reflect.String) + compTypeB := DefProduct(reflect.String) + myType := DefSum(NilType, compTypeA, compTypeB) assert.Equal(t, true, myType.Matches((1), ("1"))) assert.Equal(t, true, myType.Matches(("2"))) @@ -302,9 +300,9 @@ func TestCompType(t *testing.T) { } func TestPatternMatching(t *testing.T) { - var compTypeA = DefProduct(reflect.Int, reflect.String) - var compTypeB = DefProduct(reflect.String, reflect.String) - var myType = DefSum(NilType, compTypeA, compTypeB) + compTypeA := DefProduct(reflect.Int, reflect.String) + compTypeB := DefProduct(reflect.String, reflect.String) + myType := DefSum(NilType, compTypeA, compTypeB) assert.Equal(t, true, compTypeA.Matches(1, "3")) assert.Equal(t, false, compTypeA.Matches(1, 3)) @@ -313,7 +311,7 @@ func TestPatternMatching(t *testing.T) { assert.Equal(t, true, myType.Matches("1", "3")) assert.Equal(t, false, myType.Matches(1, 3)) - var patterns = []Pattern{ + patterns := []Pattern{ InCaseOfKind(reflect.Int, func(x interface{}) interface{} { return (fmt.Sprintf("Integer: %v", x)) }), @@ -330,7 +328,7 @@ func TestPatternMatching(t *testing.T) { return (fmt.Sprintf("got this object: %v", x)) }), } - var pm = DefPattern(patterns...) + pm := DefPattern(patterns...) assert.Equal(t, "Integer: 42", pm.MatchFor((42))) assert.Equal(t, "Hello world", pm.MatchFor(("world"))) assert.Equal(t, "Matched: ccc", pm.MatchFor(("ccc"))) diff --git a/handler.go b/handler.go index a5f5b06..b7afdf0 100644 --- a/handler.go +++ b/handler.go @@ -43,6 +43,7 @@ func (handlerSelf *HandlerDef) Close() { close(*handlerSelf.ch) } + func (handlerSelf *HandlerDef) run() { for fn := range *handlerSelf.ch { fn() diff --git a/maybe.go b/maybe.go index e51d78d..a6339d0 100644 --- a/maybe.go +++ b/maybe.go @@ -1413,5 +1413,5 @@ func (noneSelf noneDef) Kind() reflect.Kind { // None None utils instance var None = noneDef{someDef[any]{isNil: true, isPresent: false}} -//var noneAsSome = someDef[interface{}](None) +// var noneAsSome = someDef[interface{}](None) var noneAsSome = None.someDef diff --git a/maybe_test.go b/maybe_test.go index 15074ed..5b14327 100644 --- a/maybe_test.go +++ b/maybe_test.go @@ -19,7 +19,7 @@ func TestIsPresent(t *testing.T) { assert.Equal(t, false, m.IsPresent()) assert.Equal(t, true, m.IsNil()) - var i = 1 + i := 1 var iptr *int iptr = nil @@ -45,9 +45,9 @@ func TestOr(t *testing.T) { func TestClone(t *testing.T) { var m MaybeDef[interface{}] - var i = 1 - var i2 = 2 - var temp = 3 + i := 1 + i2 := 2 + temp := 3 var iptr *int var iptr2 *int iptr2 = &i2 diff --git a/monadIO.go b/monadIO.go index c09b9d1..608bad0 100644 --- a/monadIO.go +++ b/monadIO.go @@ -37,12 +37,10 @@ func MonadIONewGenerics[T any](effect func() T) *MonadIODef[T] { // FlatMap FlatMap the MonadIO by function func (monadIOSelf *MonadIODef[T]) FlatMap(fn func(T) *MonadIODef[T]) *MonadIODef[T] { - return &MonadIODef[T]{effect: func() T { next := fn(monadIOSelf.doEffect()) return next.doEffect() }} - } // Subscribe Subscribe the MonadIO by Subscription @@ -63,8 +61,8 @@ func (monadIOSelf *MonadIODef[T]) ObserveOn(h *HandlerDef) *MonadIODef[T] { monadIOSelf.obOn = h return monadIOSelf } -func (monadIOSelf *MonadIODef[T]) doSubscribe(s *Subscription[T], obOn *HandlerDef, subOn *HandlerDef) *Subscription[T] { +func (monadIOSelf *MonadIODef[T]) doSubscribe(s *Subscription[T], obOn *HandlerDef, subOn *HandlerDef) *Subscription[T] { if s.OnNext != nil { var result T @@ -89,6 +87,7 @@ func (monadIOSelf *MonadIODef[T]) doSubscribe(s *Subscription[T], obOn *HandlerD return s } + func (monadIOSelf *MonadIODef[T]) doEffect() T { return monadIOSelf.effect() } diff --git a/network/simpleHTTP.go b/network/simpleHTTP.go index 1e2bd13..effa4fb 100644 --- a/network/simpleHTTP.go +++ b/network/simpleHTTP.go @@ -219,7 +219,6 @@ func (simpleHTTPSelf *SimpleHTTPDef) DoNewRequestWithBodyOptions(context context // DoRequest Do HTTP Request with interceptors func (simpleHTTPSelf *SimpleHTTPDef) DoRequest(request *http.Request) *ResponseWithError { - response, err := simpleHTTPSelf.client.Do(request) return &ResponseWithError{ @@ -467,7 +466,6 @@ func APIMakeDoNewRequestWithMultipartSerializer[R any](simpleAPISelf *SimpleAPID func APIMakeDoNewRequest[R any](simpleAPISelf *SimpleAPIDef, method string, relativeURL string) APINoBody[R] { return APINoBody[R](func(pathParam PathParam, target *R) *fpgo.MonadIODef[*APIResponse[R]] { return fpgo.MonadIONewGenerics[*APIResponse[R]](func() *APIResponse[R] { - ctx, cancel := simpleAPISelf.GetSimpleHTTP().GetContextTimeout() defer cancel() response := simpleAPISelf.simpleHTTP.DoNewRequest(ctx, simpleAPISelf.DefaultHeader.Clone(), method, simpleAPISelf.replacePathParams(relativeURL, pathParam)) diff --git a/network/simpleHTTP_test.go b/network/simpleHTTP_test.go index 06cacdd..877c338 100644 --- a/network/simpleHTTP_test.go +++ b/network/simpleHTTP_test.go @@ -32,7 +32,6 @@ func TestSimpleAPI(t *testing.T) { var actualContentType string postsHandler := http.HandlerFunc(func(writer http.ResponseWriter, req *http.Request) { - actualRequestBody, _ = ioutil.ReadAll(req.Body) // auth := req.Header.Get("Auth") @@ -172,7 +171,6 @@ func TestSimpleAPIMultipart(t *testing.T) { var actualContentType string postsHandler := http.HandlerFunc(func(writer http.ResponseWriter, req *http.Request) { - actualRequestBody, _ = ioutil.ReadAll(req.Body) // auth := req.Header.Get("Auth") @@ -211,8 +209,8 @@ func TestSimpleAPIMultipart(t *testing.T) { actualContentType = "" postsPost := APIMakePostMultipartBody[PostListResponse](api, "posts") - sentValues = map[string][]string{"userId": []string{"0"}, "id": []string{"5"}, "title": []string{"aa"}, "body": []string{""}} - sentFiles := map[string][]string{"file": []string{filePath}} + sentValues = map[string][]string{"userId": {"0"}, "id": {"5"}, "title": {"aa"}, "body": {""}} + sentFiles := map[string][]string{"file": {filePath}} apiResponse = postsPost(nil, &MultipartForm{Value: sentValues, File: sentFiles}, &PostListResponse{}).Eval() assert.Equal(t, nil, apiResponse.Err) _, params, _ = mime.ParseMediaType(actualContentType) @@ -223,7 +221,7 @@ func TestSimpleAPIMultipart(t *testing.T) { actualContentType = "" postsPut := APIMakePutMultipartBody[PostListResponse](api, "posts") - sentValues = map[string][]string{"userId": []string{"0"}, "id": []string{"4"}, "title": []string{"bb"}, "body": []string{""}} + sentValues = map[string][]string{"userId": {"0"}, "id": {"4"}, "title": {"bb"}, "body": {""}} apiResponse = postsPut(nil, &MultipartForm{Value: sentValues}, &PostListResponse{}).Eval() assert.Equal(t, nil, apiResponse.Err) _, params, _ = mime.ParseMediaType(actualContentType) @@ -234,7 +232,7 @@ func TestSimpleAPIMultipart(t *testing.T) { actualContentType = "" postsPatch := APIMakePatchMultipartBody[PostListResponse](api, "posts") - sentValues = map[string][]string{"userId": []string{"0"}, "id": []string{"3"}, "title": []string{"cc"}, "body": []string{""}} + sentValues = map[string][]string{"userId": {"0"}, "id": {"3"}, "title": {"cc"}, "body": {""}} apiResponse = postsPatch(nil, &MultipartForm{Value: sentValues}, &PostListResponse{}).Eval() assert.Equal(t, nil, apiResponse.Err) _, params, _ = mime.ParseMediaType(actualContentType) diff --git a/publisher.go b/publisher.go index 6527a03..e9ff79a 100644 --- a/publisher.go +++ b/publisher.go @@ -95,6 +95,7 @@ func (publisherSelf *PublisherDef[T]) Publish(result T) { } } } + func (publisherSelf *PublisherDef[T]) doSubscribeSafe(fn func()) { publisherSelf.subscribeM.Lock() fn() diff --git a/publisher_test.go b/publisher_test.go index 8b28386..001ad0c 100644 --- a/publisher_test.go +++ b/publisher_test.go @@ -11,8 +11,8 @@ func TestPublisher(t *testing.T) { p := Publisher.New() p2 := p - var actual = 0 - var expected = 0 + actual := 0 + expected := 0 assert.Equal(t, expected, actual) assert.Equal(t, true, s == nil) diff --git a/queue.go b/queue.go index 0925cb4..e68c37e 100644 --- a/queue.go +++ b/queue.go @@ -500,6 +500,7 @@ func (q *BufferedChannelQueue[T]) freeNodePool() { } } } + func (q *BufferedChannelQueue[T]) loadFromPool() { for range q.loadWorkerCh { @@ -532,6 +533,7 @@ func (q *BufferedChannelQueue[T]) loadFromPool() { } } + func (q *BufferedChannelQueue[T]) notifyWorkers() { q.lock.RLock() if q.pool.Count() > 0 { diff --git a/sortDescriptor_test.go b/sortDescriptor_test.go index 2ad1a1c..4a4dbc8 100644 --- a/sortDescriptor_test.go +++ b/sortDescriptor_test.go @@ -15,15 +15,15 @@ type TestCustomObject struct { func TestSortDescriptor(t *testing.T) { objects := []TestCustomObject{ - TestCustomObject{ + { Name: NewComparableString("BC"), Age: 30, }, - TestCustomObject{ + { Name: NewComparableString("AD"), Age: 30, }, - TestCustomObject{ + { Name: NewComparableString("AB"), Age: 50, }, diff --git a/stream.go b/stream.go index cc72357..7c91160 100644 --- a/stream.go +++ b/stream.go @@ -27,24 +27,21 @@ func (streamSelf *StreamDef[T]) ToArray() []T { // Map Map all items of Stream by function func (streamSelf *StreamDef[T]) Map(fn func(T, int) T) *StreamDef[T] { - - var result = StreamFromArray(MapIndexed(fn, (*streamSelf)...)) + result := StreamFromArray(MapIndexed(fn, (*streamSelf)...)) return result } // Filter Filter items of Stream by function func (streamSelf *StreamDef[T]) Filter(fn func(T, int) bool) *StreamDef[T] { - - var result = StreamFromArray(Filter(fn, (*streamSelf)...)) + result := StreamFromArray(Filter(fn, (*streamSelf)...)) return result } // Reject Reject items of Stream by function func (streamSelf *StreamDef[T]) Reject(fn func(T, int) bool) *StreamDef[T] { - - var result = StreamFromArray(Reject(fn, (*streamSelf)...)) + result := StreamFromArray(Reject(fn, (*streamSelf)...)) return result } @@ -161,19 +158,19 @@ func (streamSelf *StreamDef[T]) Extend(streams ...*StreamDef[T]) *StreamDef[T] { return streamSelf } - var mine = *streamSelf - var mineLen = len(mine) - var totalLen = mineLen + mine := *streamSelf + mineLen := len(mine) + totalLen := mineLen for _, stream := range streams { if stream == nil { continue } - var targetLen = len(*stream) + targetLen := len(*stream) totalLen += targetLen } - var newOne = make(StreamDef[T], totalLen) + newOne := make(StreamDef[T], totalLen) for i, item := range mine { newOne[i] = item @@ -185,8 +182,8 @@ func (streamSelf *StreamDef[T]) Extend(streams ...*StreamDef[T]) *StreamDef[T] { continue } - var target = *stream - var targetLen = len(target) + target := *stream + targetLen := len(target) for j, item := range target { newOne[totalIndex+j] = item } diff --git a/streamForInterface.go b/streamForInterface.go index 20b8d5f..15a9445 100644 --- a/streamForInterface.go +++ b/streamForInterface.go @@ -148,24 +148,21 @@ func (streamSelf *StreamForInterfaceDef) ToArray() []interface{} { // Map Map all items of Stream by function func (streamSelf *StreamForInterfaceDef) Map(fn func(interface{}, int) interface{}) *StreamForInterfaceDef { - - var result = StreamForInterface.FromArray(MapIndexed(fn, (*streamSelf)...)) + result := StreamForInterface.FromArray(MapIndexed(fn, (*streamSelf)...)) return result } // Filter Filter items of Stream by function func (streamSelf *StreamForInterfaceDef) Filter(fn func(interface{}, int) bool) *StreamForInterfaceDef { - - var result = StreamForInterface.FromArray(Filter(fn, (*streamSelf)...)) + result := StreamForInterface.FromArray(Filter(fn, (*streamSelf)...)) return result } // Reject Reject items of Stream by function func (streamSelf *StreamForInterfaceDef) Reject(fn func(interface{}, int) bool) *StreamForInterfaceDef { - - var result = StreamForInterface.FromArray(Reject(fn, (*streamSelf)...)) + result := StreamForInterface.FromArray(Reject(fn, (*streamSelf)...)) return result } @@ -276,19 +273,19 @@ func (streamSelf *StreamForInterfaceDef) Extend(streams ...*StreamForInterfaceDe return streamSelf } - var mine = *streamSelf - var mineLen = len(mine) - var totalLen = mineLen + mine := *streamSelf + mineLen := len(mine) + totalLen := mineLen for _, stream := range streams { if stream == nil { continue } - var targetLen = len(*stream) + targetLen := len(*stream) totalLen += targetLen } - var newOne = make([]interface{}, totalLen) + newOne := make([]interface{}, totalLen) for i, item := range mine { newOne[i] = item @@ -300,8 +297,8 @@ func (streamSelf *StreamForInterfaceDef) Extend(streams ...*StreamForInterfaceDe continue } - var target = *stream - var targetLen = len(target) + target := *stream + targetLen := len(target) for j, item := range target { newOne[totalIndex+j] = item } diff --git a/streamForInterface_test.go b/streamForInterface_test.go index f80910b..a229f1f 100644 --- a/streamForInterface_test.go +++ b/streamForInterface_test.go @@ -17,7 +17,7 @@ func TestFromArrayMapReduceForInterface(t *testing.T) { } assert.Equal(t, "1234", tempString) s = s.Map(func(item interface{}, index int) interface{} { - var val = Maybe.Just(s.Get(index)).ToMaybe().ToString() + val := Maybe.Just(s.Get(index)).ToMaybe().ToString() var result interface{} = "v" + val return result }) @@ -34,7 +34,7 @@ func TestFromArrayMapReduceForInterface(t *testing.T) { } assert.Equal(t, "1234", tempString) s = s.Map(func(item interface{}, index int) interface{} { - var val = Maybe.Just(s.Get(index)).ToString() + val := Maybe.Just(s.Get(index)).ToString() var result interface{} = "v" + val return result }) @@ -51,7 +51,7 @@ func TestFromArrayMapReduceForInterface(t *testing.T) { } assert.Equal(t, "1234", tempString) s = s.Map(func(item interface{}, index int) interface{} { - var val, _ = Maybe.Just(s.Get(index)).ToInt() + val, _ := Maybe.Just(s.Get(index)).ToInt() var result interface{} = val * val return result }) @@ -68,7 +68,7 @@ func TestFromArrayMapReduceForInterface(t *testing.T) { } assert.Equal(t, "1234", tempString) s = s.Map(func(item interface{}, index int) interface{} { - var val, _ = Maybe.Just(s.Get(index)).ToFloat32() + val, _ := Maybe.Just(s.Get(index)).ToFloat32() var result interface{} = val * val return result }) @@ -86,7 +86,7 @@ func TestFromArrayMapReduceForInterface(t *testing.T) { assert.Equal(t, "1234", tempString) s = s.Map(func(item interface{}, index int) interface{} { - var val, _ = Maybe.Just(s.Get(index)).ToFloat64() + val, _ := Maybe.Just(s.Get(index)).ToFloat64() var result interface{} = val * val return result }) @@ -163,7 +163,7 @@ func TestFilterForInterface(t *testing.T) { assert.Equal(t, "1234", tempString) s = s.Filter(func(item interface{}, index int) bool { - var val, err = Maybe.Just(s.Get(index)).ToInt() + val, err := Maybe.Just(s.Get(index)).ToInt() return err == nil && val > 1 && val < 4 }) @@ -173,7 +173,7 @@ func TestFilterForInterface(t *testing.T) { } assert.Equal(t, "23", tempString) s = s.Reject(func(item interface{}, index int) bool { - var val, err = Maybe.Just(item).ToInt() + val, err := Maybe.Just(item).ToInt() return err == nil && val > 2 }) @@ -216,8 +216,8 @@ func TestSortForInterface(t *testing.T) { tempString = "" for _, v := range s.SortByIndex(func(i, j int) bool { - var vali, _ = Maybe.Just(s.Get(i)).ToInt() - var valj, _ = Maybe.Just(s.Get(j)).ToInt() + vali, _ := Maybe.Just(s.Get(i)).ToInt() + valj, _ := Maybe.Just(s.Get(j)).ToInt() return vali < valj }).ToArray() { tempString += Maybe.Just(v).ToMaybe().ToString() @@ -225,8 +225,8 @@ func TestSortForInterface(t *testing.T) { assert.Equal(t, "23411", tempString) tempString = "" for _, v := range s.Sort(func(a, b interface{}) bool { - var vali, _ = Maybe.Just(a).ToInt() - var valj, _ = Maybe.Just(b).ToInt() + vali, _ := Maybe.Just(a).ToInt() + valj, _ := Maybe.Just(b).ToInt() return vali < valj }).ToArray() { tempString += Maybe.Just(v).ToMaybe().ToString() @@ -272,7 +272,6 @@ func TestStreamForInterfaceSetOperation(t *testing.T) { tempString += Maybe.Just(v).ToMaybe().ToString() + "/" } assert.Equal(t, "9/6/", tempString) - } func TestSetForInterfaceSetOperation(t *testing.T) { diff --git a/stream_test.go b/stream_test.go index 0b458f8..7962ff3 100644 --- a/stream_test.go +++ b/stream_test.go @@ -34,7 +34,7 @@ func TestFromArrayMapReduce(t *testing.T) { } assert.Equal(t, "1234", tempString) s2 = s2.Map(func(item string, index int) string { - var val = Maybe.Just(item).ToString() + val := Maybe.Just(item).ToString() var result string = "v" + val return result }) @@ -206,8 +206,8 @@ func TestSort(t *testing.T) { tempString = "" for _, v := range s.SortByIndex(func(i, j int) bool { - var vali, _ = Maybe.Just(s.Get(i)).ToInt() - var valj, _ = Maybe.Just(s.Get(j)).ToInt() + vali, _ := Maybe.Just(s.Get(i)).ToInt() + valj, _ := Maybe.Just(s.Get(j)).ToInt() return vali < valj }).ToArray() { tempString += Maybe.Just(v).ToMaybe().ToString() @@ -260,7 +260,6 @@ func TestStreamSetOperation(t *testing.T) { tempString += Maybe.Just(v).ToMaybe().ToString() + "/" } assert.Equal(t, "9/6/", tempString) - } func TestSetSetOperation(t *testing.T) {