From 9caefdb67d39b28d77e0eee9a3b89a5433834866 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Mon, 10 Jan 2022 10:24:33 +0800 Subject: [PATCH] fmt: slice.go --- slice/slice.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/slice/slice.go b/slice/slice.go index 7a1f38d..0f7f20d 100644 --- a/slice/slice.go +++ b/slice/slice.go @@ -167,7 +167,7 @@ func Some(slice, function interface{}) bool { // Filter iterates over elements of slice, returning an slice of all elements `signature` returns truthy for. // The fn signature should be func(int, T) bool. -func Filter [T any] (slice []T, fn func(index int, t T) bool) []T { +func Filter[T any](slice []T, fn func(index int, t T) bool) []T { res := make([]T, 0, 0) for i, v := range slice { if fn(i, v) { @@ -279,7 +279,7 @@ func flattenRecursive(value reflect.Value, result reflect.Value) reflect.Value { // ForEach iterates over elements of slice and invokes function for each element // The fn signature should be func(int, T ). -func ForEach [T any] (slice []T, fn func(index int, t T)) { +func ForEach[T any](slice []T, fn func(index int, t T)) { for i, v := range slice { fn(i, v) } @@ -287,7 +287,7 @@ func ForEach [T any] (slice []T, fn func(index int, t T)) { // Map creates an slice of values by running each element of `slice` thru `function`. // The fn signature should be func(int, T). -func Map [T any, U any] (slice []T, fn func(index int, t T) U) []U { +func Map[T any, U any](slice []T, fn func(index int, t T) U) []U { res := make([]U, len(slice), cap(slice)) for i, v := range slice { res[i] = fn(i, v)