Documentation
¶
Index ¶
- func GetBoolPtr(m map[string]any, key string) *bool
- func GetInt64Ptr(m map[string]any, key string) *int64
- func GetPtr[T any](m map[string]any, key string) *T
- func GetSlice[T any](m map[string]any, key string) []T
- func GetSlicePtr[T any](m map[string]any, key string) []*T
- func GetStringPtr(m map[string]any, key string) *string
- func GetStringSlice(m map[string]any, key string) []string
- type Map
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) CompareAndDelete(key K, old V) (deleted bool)
- func (m *Map[K, V]) CompareAndSwap(key K, old, new V) (swapped bool)
- func (m *Map[K, V]) Delete(key K)
- func (m *Map[K, V]) Load(key K) (value V, ok bool)
- func (m *Map[K, V]) LoadAndDelete(key K) (value V, loaded bool)
- func (m *Map[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)
- func (m *Map[K, V]) Range(f func(key K, value V) bool)
- func (m *Map[K, V]) Store(key K, value V)
- func (m *Map[K, V]) Swap(key K, value V) (previous V, loaded bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBoolPtr ¶
GetBoolPtr extracts a *bool value from a map[string]any.
func GetInt64Ptr ¶
GetInt64Ptr extracts a *int64 value from a map[string]any.
func GetStringPtr ¶
GetStringPtr extracts a *string value from a map[string]any.
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map is a generic type-safe wrapper around sync.Map.
func (*Map[K, V]) CompareAndDelete ¶
CompareAndDelete deletes the entry for key if its value is equal to old.
func (*Map[K, V]) CompareAndSwap ¶
CompareAndSwap swaps the old and new values for key if the value stored in the map is equal to old.
func (*Map[K, V]) Load ¶
Load returns the value stored in the map for a key, or the zero value if no value is present. The ok result indicates whether value was found in the map.
func (*Map[K, V]) LoadAndDelete ¶
LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.
func (*Map[K, V]) LoadOrStore ¶
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.