util

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendIfNotContains

func AppendIfNotContains[T comparable](s []T, v T) []T

func ApplyToAll

func ApplyToAll[T any](s []T, f func(v T) T)

func Block

func Block(ctx context.Context)

func CleanBase added in v1.4.0

func CleanBase(dir string) string

func Contains

func Contains[T comparable](s []T, v T) bool

func ContainsAll

func ContainsAll[T comparable](s []T, v []T) bool

func ContainsAny

func ContainsAny[T comparable](s []T, v []T) bool

func Diff

func Diff[T comparable](before, after []T) (added, removed []T)

func HasDuplicates

func HasDuplicates[T constraints.Ordered](v []T) bool

func IndexOf

func IndexOf[T comparable](s []T, v T) int

func IsErrCode added in v1.5.0

func IsErrCode(err error, code int) bool

func Opt

func Opt[T any](v []T, def ...T) T

func QueryInt

func QueryInt(ctx *routing.Context, name string, def int) (int, error)

func Remove

func Remove[T comparable](s []T, v T) []T

func SplitAndClean

func SplitAndClean(v string, sep string) []string

func SplitIfNotEmpty

func SplitIfNotEmpty(v string, sep string) []string

func StartsWithAny added in v1.5.0

func StartsWithAny(v string, prefixes []string) (bool, string)

func WrapReadCloser added in v1.4.0

func WrapReadCloser(rc io.ReadCloser, afterClose func(error) error) readCloserWrapper

Types

type Waiters

type Waiters[TKey any] struct {
	// contains filtered or unexported fields
}

func (*Waiters[TKey]) BroadcastAndRemove

func (t *Waiters[TKey]) BroadcastAndRemove(key TKey) bool

func (*Waiters[TKey]) Create

func (t *Waiters[TKey]) Create(key TKey) *sync.Cond

func (*Waiters[TKey]) CreateAndWait

func (t *Waiters[TKey]) CreateAndWait(key TKey)

func (*Waiters[TKey]) Get

func (t *Waiters[TKey]) Get(key TKey) (*sync.Cond, bool)

Jump to

Keyboard shortcuts

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