common

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Getenv

func Getenv(key, fallback string) string

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

func Loop(function func(), interval time.Duration) func()

Loop wraps a function in an endless loop and calls the function in the defined interval.

func LoopWithParam added in v1.0.16

func LoopWithParam[T any](function func(T), param T, interval time.Duration) func()

func Ptr

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

Ptr delivers the pointer of any constant value like Ptr("foo")

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

func RunOnceWithParam[T any](function func(T), param T, id any)

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

func StoppableLoop(function func() bool, interval time.Duration) func()

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 StoppableLoopWithParam[T any](function func(T) bool, param T, interval time.Duration) func()

func StructToMap

func StructToMap(data any) map[string]interface{}

StructToMap converts a struct to map of struct properties

func UnmarshalFile

func UnmarshalFile[T any](path string) (T, error)

UnmarshalFile returns the content of the file as object of type T

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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