kittehs

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Taken from https://github.com/egtann/strip-wildcard-prefix/blob/main/strip_wildcard.go. See discussion in https://github.com/golang/go/issues/64909.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(xs ...bool) bool

func Any

func Any(xs ...bool) bool

func ContainedIn

func ContainedIn[T comparable](xs ...T) func(T) bool

func ErrorWithPrefix added in v0.3.0

func ErrorWithPrefix[T any](prefix T, err error) error

func FSToMap added in v0.2.0

func FSToMap(in fs.FS) (map[string][]byte, error)

func Filter

func Filter[T any](ts []T, f func(T) bool) []T

func FilterMapKeys

func FilterMapKeys[K comparable, V any](m map[K]V, f func(K) bool) map[K]V

func FilterMapValues

func FilterMapValues[K comparable, V any](m map[K]V, f func(V) bool) map[K]V

func FilterNils

func FilterNils[T any](ts []*T) []*T

func FilterZeroes added in v0.3.0

func FilterZeroes[T comparable](ts []T) []T

func FindFirst

func FindFirst[T any](vs []T, f func(T) bool) (int, T)

func FirstError

func FirstError(errs []error) error

func FoldLeft

func FoldLeft[X, A any](xs []X, f func(a A, x X) A, a A) A

func HashString32

func HashString32(s string) uint32

HashString32 computes the 32-bit FNV-1a hash of s in software. maphash.String does only 64bit version. (in Alan I trust: https://github.com/google/starlark-go/blob/f86470692795f8abcf9f837a3c53cf031c5a3d7e/starlark/hashtable.go#L435)

func HashString64

func HashString64(s string) uint64
func Head[T any](xs []T) (t T)

func IsNil

func IsNil[T any](x *T) bool

func IsNotNil

func IsNotNil[T any](x *T) bool

func IsNotZero added in v0.3.0

func IsNotZero[T comparable](t T) bool

func IsUnique

func IsUnique[X any, Y comparable](xs []X, f func(X) Y) bool

func IsZero added in v0.3.0

func IsZero[T comparable](t T) bool

func Lazy1

func Lazy1[T, P any](f func(P) T, p P) func() T

func ListToMap

func ListToMap[T any, K comparable, V any](ts []T, f func(T) (K, V)) map[K]V

This does not guard against duplicate keys.

func ListToMapError

func ListToMapError[T any, K comparable, V any](ts []T, f func(T) (K, V, error)) (map[K]V, error)

func MapFilter

func MapFilter[K comparable, V any](m map[K]V, f func(K, V) bool) map[K]V

func MapToMemFS added in v0.2.0

func MapToMemFS(in map[string][]byte) (fs.FS, error)

func MapValuesSortedByKeys

func MapValuesSortedByKeys[A cmp.Ordered, B any](m map[A]B) []B

MapValuesSortedByKeys returns a slice of the map's values in stable order.

func MatchLongestSuffix

func MatchLongestSuffix(s string, suffixes []string) string

func Must0

func Must0(err error)

func Must1

func Must1[A any](a A, err error) A

func Must11

func Must11[A, X any](f func(A) (X, error)) func(A) X

Lazy Must1 with 1 input argument.

func Must12

func Must12[A, X, Y any](f func(A) (X, Y, error)) func(A) (X, Y)

Lazy Must2 with 1 input argument.

func Must2

func Must2[A, B any](a A, b B, err error) (A, B)

func MustEqual

func MustEqual[T comparable](a, b T, msg ...any)

func NewFilter

func NewFilter[T any](f func(T) bool) func([]T) []T

func NewMapFilter

func NewMapFilter[K comparable, V any](f func(K, V) bool) func(map[K]V) map[K]V

func NewMapKeysFilter

func NewMapKeysFilter[K comparable, V any](f func(K) bool) func(map[K]V) map[K]V

func NewMapValuesFilter

func NewMapValuesFilter[K comparable, V any](f func(V) bool) func(map[K]V) map[K]V

func NormalizeURL added in v0.4.0

func NormalizeURL(rawURL string, secure bool) (string, error)

NormalizeURL ensures that the given URL has the right scheme prefix, and no suffix (e.g. path) after the host address.

func PadLeft

func PadLeft(s string, r rune, n int) string

func Panic

func Panic(msg any)

func SetPanicFunc

func SetPanicFunc(f func(any))

func Should1

func Should1[T any](alt T) func(t T, err error) T

If err is nil, return t. Else return alt.

func Should11

func Should11[X, Y any](alt Y, f func(X) (Y, error)) func(X) Y

func ShouldFunc1

func ShouldFunc1[T any](alt func(error) T) func(t T, err error) T

func ShouldFunc11

func ShouldFunc11[X, Y any](alt func(error) Y, f func(X) (Y, error)) func(X) Y

Same as Should1s, but alt is lazy.

func StripWildcardPrefix added in v0.4.4

func StripWildcardPrefix(prefix string, h http.Handler) http.Handler

func ToString

func ToString[T fmt.Stringer](t T) string

func Transform

func Transform[A, B any](as []A, f func(A) B) []B

func TransformError

func TransformError[A, B any](as []A, f func(A) (B, error)) ([]B, error)

func TransformMap

func TransformMap[A0, A1 comparable, B0, B1 any](m map[A0]B0, f func(A0, B0) (A1, B1)) map[A1]B1

func TransformMapError

func TransformMapError[A0, A1 comparable, B0, B1 any](m map[A0]B0, f func(A0, B0) (A1, B1, error)) (map[A1]B1, error)

func TransformMapToList

func TransformMapToList[K comparable, V, T any](m map[K]V, f func(K, V) T) []T

func TransformMapToListError

func TransformMapToListError[K comparable, V, T any](m map[K]V, f func(K, V) (T, error)) ([]T, error)

func TransformMapValues

func TransformMapValues[A comparable, B0, B1 any](m map[A]B0, f func(B0) B1) map[A]B1

func TransformMapValuesError

func TransformMapValuesError[A comparable, B0, B1 any](m map[A]B0, f func(B0) (B1, error)) (map[A]B1, error)

func TransformPtr

func TransformPtr[T any](in []T) (out []*T)

func TransformToStrings

func TransformToStrings[T fmt.Stringer](ts []T) []string

func TransformUnptr

func TransformUnptr[T any](in []*T) (out []T)

func TransformWithIndex

func TransformWithIndex[A, B any](as []A, f func(int, A) B) []B

func TxtarToFS added in v0.2.0

func TxtarToFS(a *txtar.Archive) (fs.FS, error)

func ValidateList

func ValidateList[T any](vs []T, f func(int, T) error) (int, error)

Returns first index with error.

func ValidateMap

func ValidateMap[K comparable, V any](m map[K]V, f func(K, V) error) error

Types

type DoNotCompare added in v0.3.0

type DoNotCompare [0]func()

type DoNotCopy added in v0.3.0

type DoNotCopy [0]sync.Mutex

type String

type String string

This is silly, but string does not implement fmt.Stringer for some reaosn.

func (String) String

func (s String) String() string

Jump to

Keyboard shortcuts

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