gollections

module
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2024 License: MIT

README

Gollections

Gollections is set of functions for slices, maps and additional implementations of data structures such as ordered map or set aimed to reduce boilerplate code.

Supports Go version 1.21.

For example, it’s need to group some users by their role names converted to lowercase:

var users = []User{
    {name: "Bob", age: 26, roles: []Role{{"Admin"}, {"manager"}}},
    {name: "Alice", age: 35, roles: []Role{{"Manager"}}},
    {name: "Tom", age: 18},
}

You can make clear code, extensive, but without dependencies:

var namesByRole = map[string][]string{}
add := func(role string, u User) {
    namesByRole[role] = append(namesByRole[role], u.Name())
}
for _, u := range users {
    if roles := u.Roles(); len(roles) == 0 {
        add("", u)
    } else {
        for _, r := range roles {
            add(strings.ToLower(r.Name()), u)
        }
    }
}
//map[:[Tom] admin:[Bob] manager:[Bob Alice]]

Or you can write more compact code using the collections API, like:

import "github.com/m4gshm/gollections/slice/convert"
import "github.com/m4gshm/gollections/slice/group"

var namesByRole = group.ByMultipleKeys(users, func(u User) []string {
    return convert.AndConvert(u.Roles(), Role.Name, strings.ToLower)
}, User.Name)
// map[:[Tom] admin:[Bob] manager:[Bob Alice]]

Installation

go get -u github.com/m4gshm/gollections

Slices

data, err := slice.Conv(slice.Of("1", "2", "3", "4", "_", "6"), strconv.Atoi)
even := func(i int) bool { return i%2 == 0 }

result := slice.Reduce(slice.Convert(slice.Filter(data, even), strconv.Itoa), op.Sum)

assert.ErrorIs(t, err, strconv.ErrSyntax)
assert.Equal(t, "24", result)

In the example is used only small set of slice functions as slice.Filter, slice.Conv slice.Convert, and slice.Reduce. More you can look in the slice package.

Shortcut packages
result := sum.Of(filter.AndConvert(data, even, strconv.Itoa))

This is a shorter version of the previous example that used short aliases sum.Of and filter.AndConvert. More shortcuts you can find by exploring slices subpackages.

Be careful when use several slice functions subsequently like slice.Filter(slice.Convert(…​)). This can lead to unnecessary RAM consumption. Consider loop instead of slice API.

Main slice functions
Instantiators
slice.Of
var s = slice.Of(1, 3, -1, 2, 0) //[]int{1, 3, -1, 2, 0}
range_.Of
import "github.com/m4gshm/gollections/slice/range_"

var increasing = range_.Of(-1, 3)    //[]int{-1, 0, 1, 2}
var decreasing = range_.Of('e', 'a') //[]rune{'e', 'd', 'c', 'b'}
var nothing = range_.Of(1, 1)        //nil
range_.Closed
var increasing = range_.Closed(-1, 3)    //[]int{-1, 0, 1, 2, 3}
var decreasing = range_.Closed('e', 'a') //[]rune{'e', 'd', 'c', 'b', 'a'}
var one = range_.Closed(1, 1)            //[]int{1}
Sorters
sort.Asc, sort.Desc
// sorting in-place API
import "github.com/m4gshm/gollections/slice/sort"

var ascendingSorted = sort.Asc([]int{1, 3, -1, 2, 0})   //[]int{-1, 0, 1, 2, 3}
var descendingSorted = sort.Desc([]int{1, 3, -1, 2, 0}) //[]int{3, 2, 1, 0, -1}
sort.By, sort.ByDesc
// sorting copied slice API does not change the original slice
import "github.com/m4gshm/gollections/slice/clone/sort"

// see the User structure above
var users = []User{
    {name: "Bob", age: 26},
    {name: "Alice", age: 35},
    {name: "Tom", age: 18},
    {name: "Chris", age: 41},
}

var byName = sort.By(users, User.Name)
//[{Alice 35 []} {Bob 26 []} {Chris 41 []} {Tom 18 []}]

var byAgeReverse = sort.DescBy(users, User.Age)
//[{Chris 41 []} {Alice 35 []} {Bob 26 []} {Tom 18 []}]
To map converters
group.Of
import "github.com/m4gshm/gollections/convert/as"
import "github.com/m4gshm/gollections/expr/use"
import "github.com/m4gshm/gollections/slice/group"

var ageGroups = group.Of(users, func(u User) string {
    return use.If(u.age <= 20, "<=20").If(u.age <= 30, "<=30").Else(">30")
}, as.Is)

//map[<=20:[{Tom 18 []}] <=30:[{Bob 26 []}] >30:[{Alice 35 []} {Chris 41 []}]]
group.ByMultipleKeys
import "github.com/m4gshm/gollections/slice/convert"
import "github.com/m4gshm/gollections/slice/group"

var namesByRole = group.ByMultipleKeys(users, func(u User) []string {
    return convert.AndConvert(u.Roles(), Role.Name, strings.ToLower)
}, User.Name)
// map[:[Tom] admin:[Bob] manager:[Bob Alice]]
slice.ToMap, slice.ToMapResolv
import (
    "github.com/m4gshm/gollections/map_/resolv"
    "github.com/m4gshm/gollections/op"
    "github.com/m4gshm/gollections/slice"
)

var ageGroupedSortedNames map[string][]string

ageGroupedSortedNames = slice.ToMapResolv(users, func(u User) string {
    return op.IfElse(u.age <= 30, "<=30", ">30")
}, User.Name, resolv.SortedSlice)

//map[<=30:[Bob Tom] >30:[Alice Chris]]
Reducers
sum.Of
import "github.com/m4gshm/gollections/op/sum"

var sum = sum.Of(1, 2, 3, 4, 5, 6) //21
slice.Reduce
var sum = slice.Reduce([]int{1, 2, 3, 4, 5, 6}, func(i1, i2 int) int { return i1 + i2 })
//21
slice.First
import "github.com/m4gshm/gollections/predicate/more"
import "github.com/m4gshm/gollections/slice"

result, ok := slice.First([]int{1, 3, 5, 7, 9, 11}, more.Than(5)) //7, true
slice.Last
import "github.com/m4gshm/gollections/predicate/less"
import "github.com/m4gshm/gollections/slice"

result, ok := slice.Last([]int{1, 3, 5, 7, 9, 11}, less.Than(9)) //7, true
Converters
slice.Convert
var s []string = slice.Convert([]int{1, 3, 5, 7, 9, 11}, strconv.Itoa)
//[]string{"1", "3", "5", "7", "9", "11"}
slice.Conv
result, err := slice.Conv(slice.Of("1", "3", "5", "_7", "9", "11"), strconv.Atoi)
//[]int{1, 3, 5}, ErrSyntax
slice.Filter
import "github.com/m4gshm/gollections/predicate/exclude"
import "github.com/m4gshm/gollections/predicate/one"
import "github.com/m4gshm/gollections/slice"

var f1 = slice.Filter([]int{1, 3, 5, 7, 9, 11}, one.Of(1, 7).Or(one.Of(11))) //[]int{1, 7, 11}
var f2 = slice.Filter([]int{1, 3, 5, 7, 9, 11}, exclude.All(1, 7, 11))       //[]int{3, 5, 9}
slice.Flat
import "github.com/m4gshm/gollections/convert/as"
import "github.com/m4gshm/gollections/slice"

var i []int = slice.Flat([][]int{{1, 2, 3}, {4}, {5, 6}}, as.Is)
//[]int{1, 2, 3, 4, 5, 6}
Operations chain functions
  • convert.AndReduce, conv.AndReduce

  • convert.AndFilter

  • filter.AndConvert

These functions combine converters, filters and reducers.

Maps

Main map functions
Instantiators
clone.Of
import "github.com/m4gshm/gollections/map_/clone"

var bob = map[string]string{"name": "Bob"}
var tom = map[string]string{"name": "Tom"}

var employers = map[string]map[string]string{
    "devops": bob,
    "jun":    tom,
}

copy := clone.Of(employers)
delete(copy, "jun")
bob["name"] = "Superbob"

fmt.Printf("%v\n", employers) //map[devops:map[name:Superbob] jun:map[name:Tom]]
fmt.Printf("%v\n", copy)      //map[devops:map[name:Superbob]]
clone.Deep
import "github.com/m4gshm/gollections/map_/clone"

var bob = map[string]string{"name": "Bob"}
var tom = map[string]string{"name": "Tom"}

var employers = map[string]map[string]string{
    "devops": bob,
    "jun":    tom,
}

copy := clone.Deep(employers, func(employer map[string]string) map[string]string {
    return clone.Of(employer)
})
delete(copy, "jun")
bob["name"] = "Superbob"

fmt.Printf("%v\n", employers) //map[devops:map[name:Superbob] jun:map[name:Tom]]
fmt.Printf("%v\n", copy)      //map[devops:map[name:Bob]]
Keys, values exrtractors
map_.Keys, map_.Values
var employers = map[string]map[string]string{
    "devops": {"name": "Bob"},
    "jun":    {"name": "Tom"},
}

keys := map_.Keys(employers)     //[devops jun]
values := map_.Values(employers) //[map[name:Bob] map[name:Tom]]
Converters
map_.ConvertKeys
var keys = map_.ConvertKeys(employers, func(title string) string {
    return string([]rune(title)[0])
})
//map[d:map[name:Bob] j:map[name:Tom]]
map_.ConvertValues
var vals = map_.ConvertValues(employers, func(employer map[string]string) string {
    return employer["name"]
})
//map[devops:Bob jun:Tom]
map_.Convert
var all = map_.Convert(employers, func(title string, employer map[string]string) (string, string) {
    return string([]rune(title)[0]), employer["name"]
})
//map[d:Bob j:Tom]
map_.Conv
var all, err = map_.Conv(employers, func(title string, employer map[string]string) (string, string, error) {
    return string([]rune(title)[0]), employer["name"], nil
})
//map[d:Bob j:Tom], nil
map_.ToSlice
var users = map_.ToSlice(employers, func(title string, employer map[string]string) User {
    return User{name: employer["name"], roles: []Role{{name: title}}}
})
//[{name:Bob age:0 roles:[{name:devops}]} {name:Tom age:0 roles:[{name:jun}]}]

loop, kv/loop and breakable versions break/loop, break/kv/loop

Low-level API for iteration based on next functions:

type (
    Loop[T any]           func() (element T, ok bool)
    KVLoop[K, V any]      func() (key K, value V, ok bool)
    BreakLoop[T any]      func() (element T, ok bool, err error)
    BreakKVLoop[K, V any] func() (key K, value V, ok bool, err error)
)

The Loop function retrieves a next element from a dataset and returns ok==true if successful.
The KVLoop behaves similar but returns a key/value pair.

even := func(i int) bool { return i%2 == 0 }
stringSeq := loop.Convert(loop.Filter(loop.Of(1, 2, 3, 4), even), strconv.Itoa)

assert.Equal(t, []string{"2", "4"}, stringSeq.Slice())

BreakLoop and BreakKVLoop are used for sources that can issue an error.

intSeq := loop.Conv(loop.Of("1", "2", "3", "ddd4", "5"), strconv.Atoi)
ints, err := loop.Slice(intSeq)

assert.Equal(t, []int{1, 2, 3}, ints)
assert.ErrorContains(t, err, "invalid syntax")

The API in most cases is similar to the slice API but with delayed computation which means that the methods don’t compute a result but only return a loop provider. The loop provider is type with a Next method that returns a next processed element.

Main loop functions
Instantiators
loop.Of, loop.S
import "github.com/m4gshm/gollections/loop"

var (
    ints    = loop.Of(1, 2, 3)
    strings = loop.S([]string{"a", "b", "c"})
)
range_.Of
import "github.com/m4gshm/gollections/loop/range_"

var increasing = range_.Of(-1, 3).Slice()    //[]int{-1, 0, 1, 2}
var decreasing = range_.Of('e', 'a').Slice() //[]rune{'e', 'd', 'c', 'b'}
var nothing = range_.Of(1, 1).Slice()        //nil
range_.Closed
var increasing = range_.Closed(-1, 3).Slice()    //[]int{-1, 0, 1, 2, 3}
var decreasing = range_.Closed('e', 'a').Slice() //[]rune{'e', 'd', 'c', 'b', 'a'}
var one = range_.Closed(1, 1).Slice()            //[]int{1}
To map converters
group.Of
import "github.com/m4gshm/gollections/convert/as"
import "github.com/m4gshm/gollections/expr/use"
import "github.com/m4gshm/gollections/loop/group"

var ageGroups = group.Of(users, func(u User) string {
    return use.If(u.age <= 20, "<=20").If(u.age <= 30, "<=30").Else(">30")
}, as.Is)

//map[<=20:[{Tom 18 []}] <=30:[{Bob 26 []}] >30:[{Alice 35 []} {Chris 41 []}]]
loop.ToMap, loop.ToMapResolv
import (
    "github.com/m4gshm/gollections/map_/resolv"
    "github.com/m4gshm/gollections/op"
    "github.com/m4gshm/gollections/loop"
)

var ageGroupedSortedNames map[string][]string

ageGroupedSortedNames = loop.ToMapResolv(loop.Of(users...), func(u User) string {
    return op.IfElse(u.age <= 30, "<=30", ">30")
}, User.Name, resolv.SortedSlice)

//map[<=30:[Bob Tom] >30:[Alice Chris]]
Reducers
sum.Of
import "github.com/m4gshm/gollections/op/sum"

var sum = sum.Of(loop.Of(1, 2, 3, 4, 5, 6)) //21
loop.Reduce
var sum = loop.Reduce(loop.Of(1, 2, 3, 4, 5, 6), func(i1, i2 int) int { return i1 + i2 })
//21
loop.First
import "github.com/m4gshm/gollections/predicate/more"
import "github.com/m4gshm/gollections/loop"

result, ok := loop.First(loop.Of(1, 3, 5, 7, 9, 11), more.Than(5)) //7, true
Converters
loop.Convert
var s []string = loop.Convert(loop.Of(1, 3, 5, 7, 9, 11), strconv.Itoa).Slice()
//[]string{"1", "3", "5", "7", "9", "11"}
loop.Conv
result, err := loop.Conv(loop.Of("1", "3", "5", "_7", "9", "11"), strconv.Atoi).Slice()
//[]int{1, 3, 5}, ErrSyntax
loop.Filter
import "github.com/m4gshm/gollections/predicate/exclude"
import "github.com/m4gshm/gollections/predicate/one"
import "github.com/m4gshm/gollections/loop"

var f1 = loop.Filter(loop.Of(1, 3, 5, 7, 9, 11), one.Of(1, 7).Or(one.Of(11))).Slice() //[]int{1, 7, 11}
var f2 = loop.Filter(loop.Of(1, 3, 5, 7, 9, 11), exclude.All(1, 7, 11)).Slice()       //[]int{3, 5, 9}
loop.Flat
import "github.com/m4gshm/gollections/convert/as"
import "github.com/m4gshm/gollections/loop"

var i []int = loop.Flat(loop.Of([][]int{{1, 2, 3}, {4}, {5, 6}}...), as.Is).Slice()
//[]int{1, 2, 3, 4, 5, 6}
Operations chain functions
  • convert.AndReduce, conv.AndReduce

  • convert.AndFilter

  • filter.AndConvert

These functions combine converters, filters and reducers.

Iterating over loops
  • (only for go 1.22) Using rangefunc All like:
for i := range range_.Of(0, 100).All {
    doOp(i)
}

don’t forget exec go env -w GOEXPERIMENT=rangefunc before compile.

  • Using for statement like:
next := range_.Of(0, 100)
for i, ok := next(); ok; i, ok = next() {
    doOp(i)
}
  • or
for next, i, ok := range_.Of(0, 100).Crank(); ok; i, ok = next() {
    doOp(i)
}
  • ForEach method
range_.Of(0, 100).ForEach(doOp)
  • or For method that can be aborted by returning Break for expected completion, or another error otherwise.
range_.Of(0, 100).For(func(i int) error {
    if i > 22 {
        return loop.Break
    }
    doOp(i)
    return nil
})

Data structures

mutable and immutable collections

Provides implelentations of Vector, Set and Map.

Mutables support content appending, updating and deleting (the ordered map implementation is not supported delete operations).
Immutables are read-only datasets.

Detailed description of implementations below.

Additional API

predicate and breakable break/predicate

Provides predicate builder api that used for filtering collection elements.

import "github.com/m4gshm/gollections/predicate/where"
import "github.com/m4gshm/gollections/slice"

bob, _ := slice.First(users, where.Eq(User.Name, "Bob"))

It is used for computations where an error may occur.

intSeq := loop.Conv(loop.Of("1", "2", "3", "ddd4", "5"), strconv.Atoi)
ints, err := loop.Slice(intSeq)

assert.Equal(t, []int{1, 2, 3}, ints)
assert.ErrorContains(t, err, "invalid syntax")
Expressions: use.If, get.If, first.Of, last.Of

Aimed to evaluate a value using conditions. May cause to make code shorter by not in all cases.
As example:

import "github.com/m4gshm/gollections/expr/use"

user := User{name: "Bob", surname: "Smith"}

fullName := use.If(len(user.surname) == 0, user.name).If(len(user.name) == 0, user.surname).
    ElseGet(func() string { return user.name + " " + user.surname })

assert.Equal(t, "Bob Smith", fullName)

instead of:

user := User{name: "Bob", surname: "Smith"}

fullName := ""
if len(user.surname) == 0 {
    fullName = user.name
} else if len(user.name) == 0 {
    fullName = user.surname
} else {
    fullName = user.name + " " + user.surname
}

assert.Equal(t, "Bob Smith", fullName)
first.Of
import "github.com/m4gshm/gollections/expr/first"
import "github.com/m4gshm/gollections/predicate/more"

result, ok := first.Of(1, 3, 5, 7, 9, 11).By(more.Than(5)) //7, true
last.Of
import "github.com/m4gshm/gollections/expr/last"
import "github.com/m4gshm/gollections/predicate/less"

result, ok := last.Of(1, 3, 5, 7, 9, 11).By(less.Than(9)) //7, true

Mutable collections

Supports write operations (append, delete, replace).

  • Vector - the simplest based on built-in slice collection.
_ *mutable.Vector[int] = vector.Of(1, 2, 3)
_ *mutable.Vector[int] = &mutable.Vector[int]{}
  • Set - collection of unique items, prevents duplicates.
_ *mutable.Set[int] = set.Of(1, 2, 3)
_ *mutable.Set[int] = &mutable.Set[int]{}
_ *mutable.Map[int, string] = map_.Of(k.V(1, "1"), k.V(2, "2"), k.V(3, "3"))
_ *mutable.Map[int, string] = mutable.NewMapOf(map[int]string{1: "2", 2: "2", 3: "3"})
  • OrderedSet - collection of unique items, prevents duplicates, provides iteration in order of addition.
_ *ordered.Set[int] = set.Of(1, 2, 3)
_ *ordered.Set[int] = &ordered.Set[int]{}
  • OrderedMap - same as the Map, but supports iteration in the order in which elements are added.
_ *ordered.Map[int, string] = map_.Of(k.V(1, "1"), k.V(2, "2"), k.V(3, "3"))
_ *ordered.Map[int, string] = ordered.NewMapOf(
    /*order  */ []int{3, 1, 2},
    /*uniques*/ map[int]string{1: "2", 2: "2", 3: "3"},
)
Immutable collections

The same underlying interfaces but for read-only use cases.

Iterating over collections
  • (only for go 1.22) Using rangefunc All like:
uniques := set.From(range_.Of(0, 100))
for i := range uniques.All {
    doOp(i)
}
  • Using for statement like:
uniques := set.From(range_.Of(0, 100))
next := uniques.Loop()
for i, ok := next(); ok; i, ok = next() {
    doOp(i)
}
  • or
uniques := set.From(range_.Of(0, 100))
for iter, i, ok := uniques.First(); ok; i, ok = iter.Next() {
    doOp(i)
}
  • ForEach method
uniques := set.From(range_.Of(0, 100))
uniques.ForEach(doOp)
  • or For method that can be aborted by returning Break for expected completion, or another error otherwise.
uniques := set.From(range_.Of(0, 100))
uniques.For(func(i int) error {
    if i > 22 {
        return loop.Break
    }
    doOp(i)
    return nil
})

Directories

Path Synopsis
break
kv
Package kv provides key/value types, functions
Package kv provides key/value types, functions
kv/loop
Package loop provides helpers for loop operation over key/value pairs.
Package loop provides helpers for loop operation over key/value pairs.
kv/loop/group
Package group provides short aliases for functions thath are used to group key/value pairs retrieved by a loop
Package group provides short aliases for functions thath are used to group key/value pairs retrieved by a loop
kv/predicate
Package predicate provides helpers for filtering keys or values of a map
Package predicate provides helpers for filtering keys or values of a map
loop
Package loop provides helpers for loop operation and iterator implementations
Package loop provides helpers for loop operation and iterator implementations
map_/convert
Package convert provides key, value convert adapters
Package convert provides key, value convert adapters
op
Package op provides generic operations that can be used for converting or reducing collections, loops, slices
Package op provides generic operations that can be used for converting or reducing collections, loops, slices
predicate
Package predicate provides breakable predicate builders
Package predicate provides breakable predicate builders
predicate/always
Package always provides constant predicate implementations
Package always provides constant predicate implementations
predicate/eq
Package eq provides predicate builder short aliases
Package eq provides predicate builder short aliases
predicate/exclude
Package exclude provides predicate builders
Package exclude provides predicate builders
predicate/less
Package less provides predicate builders
Package less provides predicate builders
predicate/more
Package more provides predicate builders
Package more provides predicate builders
predicate/not
Package not provides negalive predicate builders like 'not equals to'
Package not provides negalive predicate builders like 'not equals to'
predicate/one
Package one provides predicate builders
Package one provides predicate builders
c
Package c provides common types of containers, utility types and functions
Package c provides common types of containers, utility types and functions
Package collection consists of common operations of Iterable based collections
Package collection consists of common operations of Iterable based collections
convert
Package convert provides converation helpers for collection implementations
Package convert provides converation helpers for collection implementations
filter
Package filter provides aliases for collections filtering helpers
Package filter provides aliases for collections filtering helpers
immutable
Package immutable provides immutable collection implementations
Package immutable provides immutable collection implementations
immutable/map_
Package map_ provides immutable.Map constructors
Package map_ provides immutable.Map constructors
immutable/ordered
Package ordered provides immutable ordered collection implementations
Package ordered provides immutable ordered collection implementations
immutable/ordered/map_
Package map_ provides immutale ordered.Map constructors
Package map_ provides immutale ordered.Map constructors
immutable/ordered/set
Package set provides ordered.Set constructors and helpers
Package set provides ordered.Set constructors and helpers
immutable/set
Package set provides unordered immutable.Set constructors and helpers
Package set provides unordered immutable.Set constructors and helpers
immutable/vector
Package vector provides ordered immutable.Vector constructors and helpers
Package vector provides ordered immutable.Vector constructors and helpers
mutable
Package mutable provides implementations of mutable containers.
Package mutable provides implementations of mutable containers.
mutable/map_
Package map_ provides unordered mutable.Map constructors
Package map_ provides unordered mutable.Map constructors
mutable/ordered
Package ordered provides mutable ordered collection implementations
Package ordered provides mutable ordered collection implementations
mutable/ordered/map_
Package map_ provides mutable ordered.Map constructors
Package map_ provides mutable ordered.Map constructors
mutable/ordered/set
Package set provides mutable ordered.Set constructors and helpers
Package set provides mutable ordered.Set constructors and helpers
mutable/set
Package set provides unordered mutable.Set constructors and helpers
Package set provides unordered mutable.Set constructors and helpers
mutable/sync
Package sync provides parametrized Map implementation
Package sync provides parametrized Map implementation
mutable/vector
Package vector provides mutable.Vector constructors and helpers
Package vector provides mutable.Vector constructors and helpers
Package comparer provides builders of slices.CompareFunc comparsion functions
Package comparer provides builders of slices.CompareFunc comparsion functions
Package convert provides converting helpers
Package convert provides converting helpers
as
Package as provides as.Is alias
Package as provides as.Is alias
ptr
Package ptr provides value, pointer convert helpers
Package ptr provides value, pointer convert helpers
val
Package val provides pointer to value convert helpers
Package val provides pointer to value convert helpers
expr
first
Package first provides helpers for retrieving a first element of a slice that satisfies a condition
Package first provides helpers for retrieving a first element of a slice that satisfies a condition
get
Package get provides conditional expression builders
Package get provides conditional expression builders
last
Package last provides helpers for retrieving a last element of a slice that satisfies a condition
Package last provides helpers for retrieving a last element of a slice that satisfies a condition
use
Package use provides conditional expression builders
Package use provides conditional expression builders
internal
k
Package k provides the k.V constructor for building key/value pairs
Package k provides the k.V constructor for building key/value pairs
kv
Package kv provides generic key/value pair constructors and helpers
Package kv provides generic key/value pair constructors and helpers
convert
Package convert provides key, value convert adapters
Package convert provides key, value convert adapters
group
Package group provides short aliases for functions that are used to group collection elements
Package group provides short aliases for functions that are used to group collection elements
loop
Package loop provides helpers for loop operation over key/value pairs and iterator implementations
Package loop provides helpers for loop operation over key/value pairs and iterator implementations
loop/group
Package group provides short aliases for functions thath are used to group key/value pairs retrieved by a loop
Package group provides short aliases for functions thath are used to group key/value pairs retrieved by a loop
Package loop provides helpers for loop operation and iterator implementations
Package loop provides helpers for loop operation and iterator implementations
conv
Package conv provides loop converation helpers
Package conv provides loop converation helpers
convert
Package convert provides loop converation helpers
Package convert provides loop converation helpers
filter
Package filter provides aliases for loop filtering helpers
Package filter provides aliases for loop filtering helpers
first
Package first provides short aliases for loop functions for retrieving a first element
Package first provides short aliases for loop functions for retrieving a first element
flat
Package flat provides short aliases for loop functions
Package flat provides short aliases for loop functions
group
Package group provides short aliases for functions that are used to group elements retrieved by a loop
Package group provides short aliases for functions that are used to group elements retrieved by a loop
range_
Package range_ provides alias for the slice.Range function
Package range_ provides alias for the slice.Range function
sum
Package sum provides sum.Of alias
Package sum provides sum.Of alias
Package map_ provides map processing helper functions
Package map_ provides map processing helper functions
clone
Package clone provides map clone aliases
Package clone provides map clone aliases
filter
Package filter provides helpers for filtering keys or values of a map
Package filter provides helpers for filtering keys or values of a map
group
Package group provides short aliases for functions that are used to group key/values retieved from a source
Package group provides short aliases for functions that are used to group key/values retieved from a source
resolv
Package resolv provides values resolvers for maps that builded by ToMap-converter functions
Package resolv provides values resolvers for maps that builded by ToMap-converter functions
Package notsafe provides unsafe helper functions
Package notsafe provides unsafe helper functions
op
Package op provides generic operations that can be used for converting or reducing collections, loops, slices
Package op provides generic operations that can be used for converting or reducing collections, loops, slices
check
Package check provides common predicate functions
Package check provides common predicate functions
check/not
Package not provides negalive predicates like 'not equals to'
Package not provides negalive predicates like 'not equals to'
delay
Package delay provides functions that return anonymous functions for delayed executions.
Package delay provides functions that return anonymous functions for delayed executions.
delay/chain
Package chain provides functions call chain builder
Package chain provides functions call chain builder
delay/replace
Package replace provides builders that specifies on value replacing
Package replace provides builders that specifies on value replacing
delay/string_
Package string_ provides string builders
Package string_ provides string builders
delay/string_/join
Package join provides string builders
Package join provides string builders
delay/string_/wrap
Package wrap provides wrap string builders
Package wrap provides wrap string builders
delay/sum
Package sum provides sum.Of alias
Package sum provides sum.Of alias
string_
Package string_ provides string utils
Package string_ provides string utils
string_/join
Package join provides concatenate string utils
Package join provides concatenate string utils
string_/wrap
Package wrap provides string wrap utils
Package wrap provides string wrap utils
sum
Package sum provides sum.Of alias
Package sum provides sum.Of alias
Package over provides helpers for rangefunc feature introduced in go 1.22.
Package over provides helpers for rangefunc feature introduced in go 1.22.
Package predicate provides predicate builders
Package predicate provides predicate builders
always
Package always provides constant predicate implementations
Package always provides constant predicate implementations
eq
Package eq provides predicate builder short aliases
Package eq provides predicate builder short aliases
exclude
Package exclude provides predicate builders
Package exclude provides predicate builders
less
Package less provides predicate builders
Package less provides predicate builders
match
Package match provides short predicate constructors
Package match provides short predicate constructors
more
Package more provides predicate builders
Package more provides predicate builders
not
Package not provides negalive predicate builders like 'not equals to'
Package not provides negalive predicate builders like 'not equals to'
one
Package one provides predicate builders
Package one provides predicate builders
where
Package where provides short predicate constructors
Package where provides short predicate constructors
Package slice provides generic functions for slice types
Package slice provides generic functions for slice types
clone
Package clone provides slice clone aliases
Package clone provides slice clone aliases
clone/reverse
Package reverse provides shor aliases for cloning slices with the elements in reverse order
Package reverse provides shor aliases for cloning slices with the elements in reverse order
clone/sort
Package sort provides sorting of cloned slice elements
Package sort provides sorting of cloned slice elements
clone/stablesort
Package stablesort provides stable sorting of cloned slice elements
Package stablesort provides stable sorting of cloned slice elements
conv
Package conv provides slice converation helpers
Package conv provides slice converation helpers
convert
Package convert provides slice converation helpers
Package convert provides slice converation helpers
filter
Package filter provides aliases for slice filtering helpers
Package filter provides aliases for slice filtering helpers
first
Package first provides short aliases for slice functions for retrieving a first element
Package first provides short aliases for slice functions for retrieving a first element
flat
Package flat provides short aliases for slice functions
Package flat provides short aliases for slice functions
group
Package group provides short aliases for grouping functions
Package group provides short aliases for grouping functions
last
Package last provides helpers for retrieving the last element of a slice
Package last provides helpers for retrieving the last element of a slice
over
Package over provides helpers for rangefunc feature introduced in go 1.22.
Package over provides helpers for rangefunc feature introduced in go 1.22.
range_
Package range_ provides alias for the slice.Range function
Package range_ provides alias for the slice.Range function
reverse
Package reverse provides shor aliases for reversng order of a slice
Package reverse provides shor aliases for reversng order of a slice
sort
Package sort provides sorting in place slice elements
Package sort provides sorting in place slice elements
sort/asc
Package asc provides aliases for storing slice functions.
Package asc provides aliases for storing slice functions.
sort/desc
Package desc provides aliases for storing slice functions.
Package desc provides aliases for storing slice functions.
split
Package split provides utils for splitting slices
Package split provides utils for splitting slices
stablesort
Package stablesort provides stable sorting in place slice elements
Package stablesort provides stable sorting in place slice elements
sum
Package sum provides sum.Of alias
Package sum provides sum.Of alias
Package walk provides utilily functions for the interface Walker
Package walk provides utilily functions for the interface Walker
group
Package group provides short aliases for functions that are used to group collection elements
Package group provides short aliases for functions that are used to group collection elements

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL