utils

package
v0.0.0-...-c879681 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LoggerLevel zap.AtomicLevel

Functions

func BadDeveloperError

func BadDeveloperError(msg string)

BadDeveloperError panics with a message that indicates a bug in the code. It should only be used in places that should never be reached or can only be reached if there is a bug in the code.

func CreateCacheBucket

func CreateCacheBucket(bucket string)

CreateCacheBucket creates a cache bucket

func EvictCache

func EvictCache(bucket string, key string)

EvictCache evicts a cache entry

func GetCache

func GetCache(bucket string, key string) *interface{}

GetCache gets a cache entry

func InitLogging

func InitLogging(level zapcore.Level)

func PutCache

func PutCache(bucket string, key string, value interface{})

PutCache puts a cache entry

func WrapJsonErrorf

func WrapJsonErrorf(path string, err error, text string, args ...interface{}) error

WrapJsonErrorf wraps an error with a stack trace and adds additional formatted text information.

func WrapRange

func WrapRange(value, start, end int) int

func WrappedJsonErrorf

func WrappedJsonErrorf(path string, text string, args ...interface{}) error

WrappedJsonErrorf creates an error with a stack trace from formatted text and appends the path.

Types

type CacheBucket

type CacheBucket struct {
	Items map[string]*interface{}
}

CacheBucket is a bucket of cache entries

type NavigableMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

NavigableMap is a map that can be navigated in order of keys. It is not thread-safe.

func MapToNavigableMap

func MapToNavigableMap(entries map[string]interface{}) NavigableMap[string, interface{}]

MapToNavigableMap creates a new NavigableMap from a golang map.

func NewNavigableMap

func NewNavigableMap[K comparable, V any]() NavigableMap[K, V]

NewNavigableMap creates a new NavigableMap.

func ToNavigableMap

func ToNavigableMap(entries ...interface{}) NavigableMap[string, interface{}]

ToNavigableMap creates a new NavigableMap with given keys and values.

func (m *NavigableMap[K, V]) Clear()

Clear clears the map.

func (m *NavigableMap[K, V]) ContainsKey(key K) bool

ContainsKey returns true if the key exists.

func (m *NavigableMap[K, V]) ContainsMatchingKey(matchFunc func(K) bool) bool

ContainsMatchingKey returns true if the matching key exists.

func (m *NavigableMap[K, V]) Get(key K) V

Get returns the value associated with the key.

func (m *NavigableMap[K, V]) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (m *NavigableMap[K, V]) Keys() []K

Keys returns the keys in order.

func (m *NavigableMap[K, V]) Put(key K, value V)

Put puts the value associated with the key.

func (m *NavigableMap[K, V]) Remove(key K)

Remove removes the value associated with the key.

func (m *NavigableMap[K, V]) Size() int

Size returns the size of the map.

func (m *NavigableMap[K, V]) Sort(comparer func(K, K) int)

Sort sorts the map with the specified comparator.

func (m *NavigableMap[K, V]) Values() []V

Values returns the values in order of keys.

Jump to

Keyboard shortcuts

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