utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitErrorf

func ExitErrorf(msg string, args ...interface{})

func JoinPath

func JoinPath(elems ...string) string

func ToArray

func ToArray[T any](mp map[string]T) []T

Types

type Cache

type Cache[K comparable, V io.Closer] struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache[K comparable, V io.Closer](opts ...Option) *Cache[K, V]

func (*Cache[K, V]) Delete

func (c *Cache[K, V]) Delete(key K)

Delete deletes the item with provided key from the cache.

func (*Cache[K, V]) Flush

func (c *Cache[K, V]) Flush() error

Flush delete all items

func (*Cache[K, V]) Get

func (c *Cache[K, V]) Get(key K) (zero V, _ bool)

func (*Cache[K, V]) GetOrSet

func (c *Cache[K, V]) GetOrSet(key K, factory func() (V, error)) (zero V, set bool, err error)

func (*Cache[K, V]) Keys

func (c *Cache[K, V]) Keys() []K

func (*Cache[K, V]) Len

func (c *Cache[K, V]) Len() int

Len returns the number of items in the cache.

func (*Cache[K, V]) Set

func (c *Cache[K, V]) Set(key K, val V)

type Hex

type Hex string

type Option

type Option func(*options)

func WithCapacity

func WithCapacity(cap int) Option

type RGB

type RGB struct {
	Red   uint8
	Green uint8
	Blue  uint8
}

func Hex2RGB

func Hex2RGB(hex Hex) (RGB, error)

type Whitelist

type Whitelist struct {
	// contains filtered or unexported fields
}

func NewWhitelist

func NewWhitelist(allowedValues map[interface{}]bool) *Whitelist

func (*Whitelist) Check

func (w *Whitelist) Check(value interface{}) bool

Jump to

Keyboard shortcuts

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