utils

package
v0.0.0-...-17e524c Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseWithLogging

func CloseWithLogging[T interface{ Close() error }](label string, closeable T)

func HostOnly

func HostOnly(endpoint string) string

func Panicf

func Panicf(format string, args ...any)

func ParseBinFile

func ParseBinFile(binFile string) iter.Seq2[BinLine, error]

func Ptr

func Ptr[T any](v T) *T

func RandString

func RandString(n int) string

RandString returns a base64 encoded string of n bytes.

func RunGoroutine

func RunGoroutine(ctx context.Context, fn func(ctx context.Context) error) (done chan error)

RunGoroutine runs a goroutine that can be cancelled using ctx. It returns a channel that is closed when the goroutine exits, and will contain an error if one occurred that was not a cancellation error (context.DeadlineExceeded or context.Canceled).

func Sleep

func Sleep(ctx context.Context, duration time.Duration) error

func SortedKeys

func SortedKeys[T any](m map[string]T) []string

Types

type BinLine

type BinLine struct {
	Label  string
	Packet []byte
}

type SyncMap

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

SyncMap is a sync.Map, just with typesafe wrapper functions.

func (*SyncMap[KeyT, ValueT]) Delete

func (sm *SyncMap[KeyT, ValueT]) Delete(key KeyT)

func (*SyncMap[KeyT, ValueT]) Load

func (sm *SyncMap[KeyT, ValueT]) Load(key KeyT) ValueT

func (*SyncMap[KeyT, ValueT]) Store

func (sm *SyncMap[KeyT, ValueT]) Store(key KeyT, value ValueT)

Jump to

Keyboard shortcuts

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