Documentation ¶
Index ¶
- func Filter(rules [][]FilterRule, properties map[string]string) (bool, error)
- func Getenv(key, fallback string) string
- func Loop(function func(), interval time.Duration) func()
- func LoopWithParam[T any](function func(T), param T, interval time.Duration) func()
- func Ptr[T any](v T) *T
- func RunOnce(function func(), id any)
- func RunOnceWithParam[T any](function func(T), param T, id any)
- func StoppableLoop(function func() bool, interval time.Duration) func()
- func StoppableLoopWithParam[T any](function func(T) bool, param T, interval time.Duration) func()
- func StructToMap(data any) map[string]interface{}
- func UnmarshalFile[T any](path string) (T, error)
- func Val[T any](v *T) T
- func WaitFor(functions ...func())
- func WaitForWithOs(functions ...func())
- type FilterRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶ added in v1.0.22
func Filter(rules [][]FilterRule, properties map[string]string) (bool, error)
Filter checks whether the properties adhere to the rules provided.
The rules are a two-dimensional array where the first dimension is joined by a logical disjunction ("OR") and the second one by a logical conjunction ("AND").
The properties can be the for example the name and MAC address of a device.
func Getenv ¶
Getenv reads the value from environment variable named by key. If the key is not defined as environment variable the default string is returned.
func Loop ¶
Loop wraps a function in an endless loop and calls the function in the defined interval.
func LoopWithParam ¶ added in v1.0.16
func RunOnce ¶
func RunOnce(function func(), id any)
RunOnce starts a function if this function not currently running. RunOnce knows, with function is currently running (identified by id) and skips starting the function again.
func RunOnceWithParam ¶ added in v1.0.18
RunOnceWithParam starts a function if this function not currently running. RunOnce knows, with function is currently running (identified by id) and skips starting the function again.
func StoppableLoop ¶ added in v1.0.16
StoppableLoop wraps a function in a loop and calls the function in the defined interval until the function return false.
func StoppableLoopWithParam ¶ added in v1.0.16
func StructToMap ¶
StructToMap converts a struct to map of struct properties
func UnmarshalFile ¶
UnmarshalFile returns the content of the file as object of type T
func Val ¶ added in v1.0.63
func Val[T any](v *T) T
Val return the value from pointer or if nil the default value
func WaitFor ¶
func WaitFor(functions ...func())
WaitFor helps to start multiple functions in parallel and waits until all functions are completed.
func WaitForWithOs ¶ added in v1.0.11
func WaitForWithOs(functions ...func())
WaitForWithOs helps to start multiple functions in parallel and waits until all functions are completed or if system signals termination