util

package
v0.0.0-...-b17c507 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(s []string, str string) bool

contains * checks if a string is present in a slice (aka an array) * PARAM s: the list/slice of strings to check * PARAM str: the string to check for * RETURNS: true if the string is present in the slice, false otherwise * from: https://freshman.tech/snippets/go/check-if-slice-contains-element/

func GetUniqueName

func GetUniqueName(num uint32, offset uint32) string

func Max

func Max(x, y uint32) uint32

Max returns the larger of x or y.

func RemoveMatching

func RemoveMatching(a []string, b []string) []string

removeMatching (UNTESTED) * removes all elements from a slice that match elements from another slice * PARAM a: the slice to remove elements from * PARAM b: the slice of match elements to remove from a * RETURNS: the slice a with all matching elements removed

func RemoveString

func RemoveString(s []string, f string) []string

RemoveString removes a string from a slice of strings

Types

type EventSub

type EventSub[Typ any] struct {
	// contains filtered or unexported fields
}

EventSub is a simple fan-out event subscription system using go channels. based on PubSub from https://eli.thegreenplace.net/2020/pubsub-using-channels-in-go/

func NewEventSub

func NewEventSub[Typ any](bufferAmt uint) *EventSub[Typ]

NewEventSub creates a new EventSub struct of the passed type with the given buffer amount bufferAmt is the number of messages that can be pushed onto the event sub without subscribers reading the message(s) before the channel blocks (1 or greater is recommended)

func (*EventSub[Typ]) Close

func (es *EventSub[Typ]) Close()

func (*EventSub[Typ]) Push

func (es *EventSub[Typ]) Push(data *Typ)

func (*EventSub[Typ]) Subscribe

func (es *EventSub[Typ]) Subscribe() <-chan *Typ

func (*EventSub[Typ]) UnSubscribe

func (es *EventSub[Typ]) UnSubscribe(c *<-chan *Typ)

type UnblockSignal

type UnblockSignal struct {
	HasTriggered bool
	// contains filtered or unexported fields
}

UnblockSignal * simple wrapper around a go channel to make it easier to block a goroutine from continuing and then let it continue when Trigger() is called * EXAMPLE USE: exiting a goroutine when some error happens in another goroutine

func NewUnblockSignal

func NewUnblockSignal() UnblockSignal

func (*UnblockSignal) GetError

func (e *UnblockSignal) GetError() error

func (*UnblockSignal) GetSignal

func (e *UnblockSignal) GetSignal() chan bool

func (*UnblockSignal) Trigger

func (e *UnblockSignal) Trigger()

func (*UnblockSignal) TriggerWithError

func (e *UnblockSignal) TriggerWithError(err error)

func (*UnblockSignal) Wait

func (e *UnblockSignal) Wait() error

Jump to

Keyboard shortcuts

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