/collections-go

Golang collections for builtin types and generic slices

Primary LanguageGoMIT LicenseMIT

collections-go

Build Status Go Report Card GoDoc

Mutable and immutable collections for commonly used builtin types. This package includes collection types generated by collections-gen for the following builtins:

In addition to that the following hand crafted collection types are included:

Installation

go get github.com/martinohmann/collections-go

Usage

c := collections.NewString([]string{"foo", "bar", "baz"})

items := c.
    Filter(func(item string) bool {
        return strings.HasPrefix(item, "ba")
    }).
    Reverse().
    Prepend("qux").
    Items()

fmt.Println(items)

// Output:
// [qux baz bar]

Check out the godocs for all available collection methods.

License

The source code of collections-go is released under the MIT License. See the bundled LICENSE file for details.