godash is a utility package in Go that provides a collection of functions for common array, math, and functional-style operations inspired by libraries like Lodash.
go get github.com/omgupta1608/godashimport "github.com/omgupta1608/godash"Splits arr into chunks of size. If size is nil or 0, defaults to 1.
Concatenates arr with args.
Drops the first n elements from arr. Defaults to 1 if n is nil.
Drops the last n elements from arr. Defaults to 1 if n is nil.
Checks if val exists in arr.
Returns the index of the first match for val in arr.
Returns the first element of arr, or nil if empty.
Returns the last element of arr, or nil if empty.
Returns all but the last element of arr.
Returns an array of unique values that are present in all arrays.
Joins the elements in arr into a string with separator sep.
Returns the sum of two numbers.
Returns the smallest integer value greater than or equal to a.
Returns the result of a / b. Returns an error if dividing by zero.
Returns the average of elements in arr.
Applies iteratee to elements before calculating the mean.
Returns the maximum number in arr.
Applies iteratee to rank elements and returns the max.
Returns the minimum number in arr.
Applies iteratee to rank elements and returns the min.
Returns the product of two numbers.
Rounds value to the specified number of decimal places.
Returns the sum of elements in arr.
Applies iteratee to elements before summing.
Clamps num within [lower, upper] bounds. If lower is nil, only upper bound is enforced.
Checks if num is within range defined by one or two values. Behaves like Lodash _.inRange.
The Iterable[T] struct enables chaining-like behavior for collections.
iter := godash.Iterable[int]{Val: []int{1, 2, 3, 4}}Returns a new iterable by applying f to each element.
Applies f to each element without returning a new iterable.
Returns a new iterable with elements passing the predicate f.
Reduces elements to a single value using f.
Returns the first element satisfying the predicate f.
Returns the index of the first element satisfying f.
Returns true if all elements satisfy f.
Returns true if any element satisfies f.
Appends elements to the iterable.
Fills a range [start:end] with the given value.
You can run tests to ensure if everything is working.
make tests