util

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDefaultContext

func CreateDefaultContext() (context.Context, context.CancelFunc)

CreateDefaultContext will create a default context which will be cancelled if the program is terminated The terminal state will be automatically restored if it was altered in any way

func RandHexString

func RandHexString(n int, startsWithletter bool) string

RandHexString generates a random hexadecimal string

func SeedMathRand

func SeedMathRand()

SeedMathRand initializes the random generator

func SortedMapKeys

func SortedMapKeys[V any](m map[string]V) []string

func StringSliceContains

func StringSliceContains(slice []string, search string) bool

StringSliceContains tells whether a contains x.

Types

type Done

type Done struct {
	// contains filtered or unexported fields
}

Done is a lazily created channel which can be used to signal clients when an action is done It's similar to context.Context's Done function

func (*Done) Close

func (d *Done) Close(err error)

func (*Done) Done

func (d *Done) Done() <-chan struct{}

func (*Done) Err

func (d *Done) Err() error

type WaitGroup

type WaitGroup struct {
	// contains filtered or unexported fields
}

WaitGroup is a slightly different version of sync.WaitGroup with error handling and Wait() returns with a channel instead of blocking.

func (*WaitGroup) Add

func (w *WaitGroup) Add(delta int)

func (*WaitGroup) Done

func (w *WaitGroup) Done(err error)

func (*WaitGroup) Err

func (w *WaitGroup) Err() error

func (*WaitGroup) Run

func (w *WaitGroup) Run(f func() error)

func (*WaitGroup) Wait

func (w *WaitGroup) Wait() <-chan struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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