safety

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package safety is a package that provides a map with safety.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyValueCtx added in v0.0.2

func CopyValueCtx(ctx context.Context) context.Context

func Go

func Go(ctx context.Context, name string, f func(context.Context) error, logger log.Interface)

Types

type Map

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

func NewMap

func NewMap[K comparable, V any](m map[K]V) *Map[K, V]

func (*Map[K, V]) Append

func (m *Map[K, V]) Append(ms ...map[K]V) *Map[K, V]

func (*Map[K, V]) Clear

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

func (*Map[K, V]) Clone

func (m *Map[K, V]) Clone() *Map[K, V]

func (*Map[K, V]) Delete

func (m *Map[K, V]) Delete(k K) *Map[K, V]

func (*Map[K, V]) DeleteFunc

func (m *Map[K, V]) DeleteFunc(f func(k K, v V) bool) *Map[K, V]

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(k K) (V, bool)

func (*Map[K, V]) Keys

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

func (*Map[K, V]) Len

func (m *Map[K, V]) Len() int

func (*Map[K, V]) Map

func (m *Map[K, V]) Map() map[K]V

func (*Map[K, V]) MarshalBinary

func (m *Map[K, V]) MarshalBinary() (data []byte, err error)

func (*Map[K, V]) Range

func (m *Map[K, V]) Range(f func(k K, v V) bool)

func (*Map[K, V]) Scan added in v0.0.2

func (m *Map[K, V]) Scan(src any) error

Scan implements sql.Scanner.

func (*Map[K, V]) Set

func (m *Map[K, V]) Set(k K, v V) *Map[K, V]

func (*Map[K, V]) String

func (m *Map[K, V]) String() string

func (*Map[K, V]) UnmarshalBinary

func (m *Map[K, V]) UnmarshalBinary(data []byte) error

func (*Map[K, V]) Value added in v0.0.2

func (m *Map[K, V]) Value() (driver.Value, error)

Value implements driver.Valuer.

func (*Map[K, V]) Values

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

type Slice

type Slice[T any] struct {
	// contains filtered or unexported fields
}

func NewSlice

func NewSlice[T any](s []T) *Slice[T]

func (*Slice[T]) Append

func (s *Slice[T]) Append(v T) *Slice[T]

func (*Slice[T]) AppendSlice

func (s *Slice[T]) AppendSlice(ss ...[]T) *Slice[T]

func (*Slice[T]) Clear

func (s *Slice[T]) Clear() *Slice[T]

func (*Slice[T]) Clone

func (s *Slice[T]) Clone() *Slice[T]

func (*Slice[T]) Delete

func (s *Slice[T]) Delete(i int) *Slice[T]

func (*Slice[T]) DeleteFunc

func (s *Slice[T]) DeleteFunc(f func(v T) bool) *Slice[T]

func (*Slice[T]) Get

func (s *Slice[T]) Get(i int) T

func (*Slice[T]) Len

func (s *Slice[T]) Len() int

func (*Slice[T]) List

func (s *Slice[T]) List() []T

func (*Slice[T]) MarshalBinary

func (s *Slice[T]) MarshalBinary() ([]byte, error)

func (*Slice[T]) Range

func (s *Slice[T]) Range(f func(v T) bool)

func (*Slice[T]) Set

func (s *Slice[T]) Set(i int, v T) *Slice[T]

func (*Slice[T]) String

func (s *Slice[T]) String() string

func (*Slice[T]) UnmarshalBinary

func (s *Slice[T]) UnmarshalBinary(data []byte) error

type SyncMap

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

SyncMap is a thread-safe map that wraps sync.Map. The mu mutex is only used to protect the m pointer during replacement (e.g., Clear, Unmarshal). All other operations rely on sync.Map's internal concurrency safety.

func NewSyncMap

func NewSyncMap[K comparable, V any](m map[K]V) *SyncMap[K, V]

func (*SyncMap[K, V]) Append

func (m *SyncMap[K, V]) Append(ms ...map[K]V) *SyncMap[K, V]

func (*SyncMap[K, V]) Clear

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

func (*SyncMap[K, V]) Clone

func (m *SyncMap[K, V]) Clone() *SyncMap[K, V]

func (*SyncMap[K, V]) Delete

func (m *SyncMap[K, V]) Delete(k K) *SyncMap[K, V]

func (*SyncMap[K, V]) DeleteFunc

func (m *SyncMap[K, V]) DeleteFunc(f func(k K, v V) bool) *SyncMap[K, V]

func (*SyncMap[K, V]) Get

func (m *SyncMap[K, V]) Get(k K) (V, bool)

func (*SyncMap[K, V]) Keys

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

func (*SyncMap[K, V]) Len

func (m *SyncMap[K, V]) Len() int

func (*SyncMap[K, V]) Map

func (m *SyncMap[K, V]) Map() map[K]V

func (*SyncMap[K, V]) MarshalBinary

func (m *SyncMap[K, V]) MarshalBinary() ([]byte, error)

func (*SyncMap[K, V]) Range

func (m *SyncMap[K, V]) Range(f func(k K, v V) bool)

func (*SyncMap[K, V]) Set

func (m *SyncMap[K, V]) Set(k K, v V) *SyncMap[K, V]

func (*SyncMap[K, V]) String

func (m *SyncMap[K, V]) String() string

func (*SyncMap[K, V]) UnmarshalBinary

func (m *SyncMap[K, V]) UnmarshalBinary(data []byte) error

func (*SyncMap[K, V]) Values

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

Jump to

Keyboard shortcuts

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