Documentation ¶
Index ¶
- Constants
- func CastInt64ToUint(in *int64) (uint, error)
- func CastToStringMapSlice(iface interface{}) []map[string]string
- func CastToStringMapSliceE(iface interface{}) ([]map[string]string, error)
- func Hash(s string) uint32
- func IncUint(value uint, by int) uint
- func Must(v interface{}, err error) interface{}
- func SubUint(a uint, by uint) int
- func SubUint2(a uint, by uint) uint
- type LatestGradient
- type SimpleTime
Constants ¶
const ( MaxUint = ^uint(0) MinUint = 0 MaxInt = int(MaxUint >> 1) MinInt = -MaxInt - 1 )
Variables ¶
This section is empty.
Functions ¶
func CastInt64ToUint ¶
CastInt64ToUint safely casts the given int64 pointer value to uint value. If the input is nil then an error will be returned. If the input is < 0 then 0 is returned.
func CastToStringMapSlice ¶
CastToStringMapSlice casts the given input to a slice of string:string map's
func CastToStringMapSliceE ¶
CastToStringMapSliceE casts the given input to a slice of string:string map's
func IncUint ¶
IncUint increments the given value (unsigned) by the given amount (signed) and returns the result as unsigned int (safe from under-/overflow)
func Must ¶
func Must(v interface{}, err error) interface{}
Must is a helper that checks if a error returned by a function is nil in this case Must will end the program with a fatal printing out the error. If the error is nil the result of the function will be returned.
Types ¶
type LatestGradient ¶
type LatestGradient struct { Value float32 Timestamp time.Time // contains filtered or unexported fields }
LatestGradient is a structure that can be used to calculate the gradient of the two latest values of a field.
func (*LatestGradient) Get ¶
func (lg *LatestGradient) Get(value float32, timestamp time.Time) float32
Get returns the gradient.
func (*LatestGradient) Update ¶
func (lg *LatestGradient) Update(value float32, timestamp time.Time)
Update sets new values for the gradient.
func (*LatestGradient) UpdateAndGet ¶
func (lg *LatestGradient) UpdateAndGet(value float32, timestamp time.Time) float32
UpdateAndGet is a thread safe method to calculate the gradient between the latest value and the current value. With each call to UpdateAndGet the given value and timestamp are stored internally. Furthermore the gradient is calculated by (currentValue-lastValue)/(currentTimeStamp-lastTimestamp).
type SimpleTime ¶ added in v0.0.12
SimpleTime just to express hours and minutes
func NewTime ¶ added in v0.0.12
func NewTime(hour, minute uint) (SimpleTime, error)
NewTime creates a new SimpleTime instance based on the given parameters
func NewTimeFromMinute ¶ added in v0.0.12
func NewTimeFromMinute(minutes uint) (SimpleTime, error)
NewTimeFromMinute creates a new SimpleTime instance based on the given parameters
func (SimpleTime) Minutes ¶ added in v0.0.12
func (s SimpleTime) Minutes() uint
Minutes returns the time in minutes
func (SimpleTime) String ¶ added in v0.0.12
func (s SimpleTime) String() string