common

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 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 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 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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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