utils

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All added in v0.4.1

func All(a []bool) bool

All takes a []bool and returns true if all of the values are true, else false.

func Any added in v0.4.1

func Any(a []bool) bool

Any takes a []bool and returns true if any of the values are true. If none are true, returns false.

func DNSSafeName

func DNSSafeName(name string) string

DNSSafeName converts an externally-supplied hostname into one that is safe to be used in a DNS record.

func Filter

func Filter[V any](f func(V) bool, source []V) []V

Filter returns a new slice with f() applied to each element to determine whether that element should be included in the new slice. Unlike FilterErr, the function should only return a bool depending on whether it should be filtered through or not.

func FilterErr added in v0.4.1

func FilterErr[V any](f func(V) (bool, error), source []V) ([]V, error)

FilterErr returns a new slice with f() applied to each element to determine whether that element should be included in the new slice. Unlike Filter, the function should return (bool, error) and if an error is returned, FilterErr immediately bubbles the error up instead of continuing with the loop.

func Map added in v0.4.0

func Map[A any, B any](f func(A) B, source []A) []B

Map calls function f for each item in source slice. Unlike MapErr, the function should only return the B type.

func MapErr added in v0.4.1

func MapErr[A any, B any](f func(A) (B, error), source []A) ([]B, error)

MapErr calls function f for each item in source slice. Unlike Map, the function should return (B, error) and if an error is returned, MapErr immatately bubbles the error up instead of continuing the loop.

func NewSprout added in v0.8.0

func Reversed

func Reversed[V any](source []V) []V

Reversed returns a reversed copy of a slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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