collections

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package collections provides generic filtering and searching utilities for filterable and named items.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterMap

func FilterMap[T models.NamedFilterable](
	g map[string][]T,
	key *string,
	name *string,
	filter string,
	pred func(T) bool,
) map[string][]T

FilterMap returns a map of filtered items from the input map, filtered by key, name, filter, and an optional predicate.

func FilterMapOrAll added in v0.2.0

func FilterMapOrAll[T models.NamedFilterable](g map[string][]T, filter string) map[string][]T

FilterMapOrAll returns g unchanged when filter is empty, and a filtered copy otherwise. Useful for the common case where callers want "all rows when no filter is set" without conditional plumbing at every callsite.

func FilterSlice

func FilterSlice[T models.NamedFilterable](items []T, name *string, filter string, pred func(T) bool) []T

FilterSlice returns a slice of items that match the filter and name. If pred is non-nil, the item must also satisfy pred(item).

func FindByName

func FindByName[T models.NamedItem](items []T, name string) *T

FindByName returns a pointer to the item with the given name, or nil if not found.

func IsMatch

func IsMatch(item models.Filterable, filter string, ignoreCase bool) bool

IsMatch returns true if the item matches the filter string, optionally ignoring case.

Types

This section is empty.

Jump to

Keyboard shortcuts

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