Documentation ¶
Overview ¶
Package utils provides utility functions for the application
Index ¶
- func AllContains[T comparable](slices1, slices2 []T) bool
- func AnyContains[T comparable](slices1, slices2 []T) bool
- func Contains[T comparable](slice []T, elem T) bool
- func CreateFileWithDir(filePath string) (*os.File, error)
- func GenerateRandomBytes(size int) ([]byte, error)
- func GenerateRandomString(length int) (string, error)
- func GenerateRandomStringWithCharset(length int, charset string) string
- func GenerateUniqueID() string
- func NewSyncMapFromMap(m map[string]any) *sync.Map
- func RemoveElement[T comparable](slice []T, elem T) []T
- type Broadcaster
- type DelayedTransport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllContains ¶
func AllContains[T comparable](slices1, slices2 []T) bool
AllContains checks if all of the slices contain a specific element
func AnyContains ¶
func AnyContains[T comparable](slices1, slices2 []T) bool
AnyContains checks if any of the slices contains a specific element
func Contains ¶
func Contains[T comparable](slice []T, elem T) bool
Contains checks if a slice contains a specific element
func CreateFileWithDir ¶
CreateFileWithDir creates a file with the directory
func GenerateRandomBytes ¶
GenerateRandomBytes generates a random byte slice of the given size.
func GenerateRandomString ¶
GenerateRandomString generates a random string of the given length
func GenerateRandomStringWithCharset ¶
GenerateRandomStringWithCharset generates a random string of the given length with the given charset.
func NewSyncMapFromMap ¶
NewSyncMapFromMap creates a new sync.Map from a map
func RemoveElement ¶
func RemoveElement[T comparable](slice []T, elem T) []T
RemoveElement removes an element from a slice
Types ¶
type Broadcaster ¶
type Broadcaster[T any] struct { // contains filtered or unexported fields }
Broadcaster is a type that broadcasts a value to multiple subscribers.
func NewBroadcaster ¶
func NewBroadcaster[T any]() *Broadcaster[T]
NewBroadcaster creates a new Broadcaster.
func (*Broadcaster[T]) Broadcast ¶
func (b *Broadcaster[T]) Broadcast(value T) <-chan struct{}
Broadcast broadcasts a value to all subscribers.
func (*Broadcaster[T]) Subscribe ¶
func (b *Broadcaster[T]) Subscribe() <-chan T
Subscribe subscribes to the Broadcaster.
func (*Broadcaster[T]) Unsubscribe ¶
func (b *Broadcaster[T]) Unsubscribe(ch chan T)
Unsubscribe unsubscribes from the Broadcaster.
type DelayedTransport ¶
type DelayedTransport struct { Transport http.RoundTripper Delay time.Duration }
DelayedTransport is an http.RoundTripper that introduces a delay before