Documentation ¶
Index ¶
- Constants
- func BoolSwitch[T interface{}](s bool, t, f T) T
- func CompareInt(a, b int) bool
- func CompareInt64(a, b int64) bool
- func CompareInt64p(a, b *int64) bool
- func CompareIntp(a, b *int) bool
- func CompareJSON(a, b interface{}) (bool, error)
- func CreateSignalContext(ctx context.Context) context.Context
- func NewType[T interface{}](input T) *T
- func NewTypeOrNil[T interface{}](input *T) *T
- func NormalizeEnv(env string) string
- func ParallelThread(max int) (chan struct{}, func())
- func ParseAgencyTime(s string) (time.Time, bool)
- func ParseTime(s string, layouts ...string) (time.Time, int)
- func RunParallel(max int, actions ...func() error) error
- func SHA256(data []byte) string
- func SHA256FromJSON(a interface{}) (string, error)
- func SHA256FromString(data string) string
- func SortKeys(m interface{}) []string
- func TimeAgencyLayouts() []string
- func TimeCompareEqual(a, b meta.Time) bool
- func TimeCompareEqualPointer(a, b *meta.Time) bool
- func TypeOrDefault[T interface{}](input *T, defaultValue ...T) T
- type Close
- type EnvironmentVariable
- type Interval
Constants ¶
const TimeLayout = time.RFC3339
Variables ¶
This section is empty.
Functions ¶
func BoolSwitch ¶
func BoolSwitch[T interface{}](s bool, t, f T) T
BoolSwitch define bool switch for defined types - in case of true t T is returned, in case of false f T
func CompareInt ¶
func CompareInt64 ¶
func CompareInt64p ¶
func CompareIntp ¶
func CompareJSON ¶
func CreateSignalContext ¶
CreateSignalContext creates and returns the context which is closed when one of the provided signal occurs. SIGINT and SIGTERM is used by default.
func NewType ¶
func NewType[T interface{}](input T) *T
NewType returns a reference to a simple type with given value.
func NewTypeOrNil ¶
func NewTypeOrNil[T interface{}](input *T) *T
NewTypeOrNil returns nil if input is nil, otherwise returns a clone of the given value.
func NormalizeEnv ¶
NormalizeEnv normalizes environment variables.
func ParallelThread ¶
func ParallelThread(max int) (chan struct{}, func())
func RunParallel ¶
RunParallel runs actions parallelly throttling them to the given maximum number.
func SHA256FromJSON ¶
func SHA256FromString ¶
func TimeAgencyLayouts ¶
func TimeAgencyLayouts() []string
func TimeCompareEqual ¶
TimeCompareEqual compares two times, allowing an error of 1s
func TimeCompareEqualPointer ¶
TimeCompareEqualPointer compares two times, allowing an error of 1s
func TypeOrDefault ¶
func TypeOrDefault[T interface{}](input *T, defaultValue ...T) T
TypeOrDefault returns the default value (or T default value) if input is nil, otherwise returns the referenced value.
Types ¶
type EnvironmentVariable ¶
type EnvironmentVariable string
EnvironmentVariable is a wrapper to get environment variables
func (EnvironmentVariable) Exists ¶
func (e EnvironmentVariable) Exists() bool
Exists check if variable is defined
func (EnvironmentVariable) Get ¶
func (e EnvironmentVariable) Get() string
Get fetch variable. If variable does not exist empty string is returned
func (EnvironmentVariable) GetOrDefault ¶
func (e EnvironmentVariable) GetOrDefault(d string) string
GetOrDefault fetch variable. If variable is not defined default value is returned
func (EnvironmentVariable) Lookup ¶
func (e EnvironmentVariable) Lookup() (string, bool)
Lookup for environment variable
func (EnvironmentVariable) String ¶
func (e EnvironmentVariable) String() string
String return string representation of environment variable name
type Interval ¶
Interval is a specialization of Duration so we can add some helper functions to that.
func (Interval) After ¶
After waits for the interval to elapse and then sends the current time on the returned channel.
func (Interval) IncreaseTo ¶
IncreaseTo returns an interval that is equal to max(x, i).