Documentation ¶
Overview ¶
Package helpers contains helpers functions.
Index ¶
- Constants
- func CeilDateSeconds(step float64) float64
- func CeilIn24System(input float64) float64
- func CeilIn60System(input float64) float64
- func CeilWithStep(input float64, step float64) float64
- func CmpDecimal(a bson.Decimal128, b bson.Decimal128) int
- func CmpDecimalProxy(a DecimalProxy, b DecimalProxy) int
- func DataToString(data interface{}) string
- func DecimalToDouble(input bson.Decimal128) float64
- func DoubleToDecimal(input float64) bson.Decimal128
- func FloorWithStep(input float64, step float64) float64
- func FromDoubleTo(t string, v float64, location *time.Location) interface{}
- func GetBSONFieldName(t interface{}, name string) string
- func GetJSONFieldName(t interface{}, name string) string
- func GetYAMLFieldName(t interface{}, name string) string
- func HashData(input interface{}) uint32
- func InStringSlice(v string, s []string) bool
- func MarshalToJSON(data interface{}) string
- func MarshalToYAML(data interface{}) string
- func MaxBool(a, b bool) bool
- func MaxDate(a, b time.Time) time.Time
- func MaxDecimal(a, b bson.Decimal128) bson.Decimal128
- func MaxDouble(a, b float64) float64
- func MaxInt(a, b int) int
- func MaxInt32(a, b int32) int32
- func MaxLong(a, b int64) int64
- func MaxObjectId(a, b bson.ObjectId) bson.ObjectId
- func MaxString(a, b string) string
- func MaxT(t string, a interface{}, b interface{}) interface{}
- func MaxTimestamp(a, b bson.MongoTimestamp) bson.MongoTimestamp
- func MaxUInt(a, b uint) uint
- func MinBool(a, b bool) bool
- func MinDate(a, b time.Time) time.Time
- func MinDecimal(a, b bson.Decimal128) bson.Decimal128
- func MinDouble(a, b float64) float64
- func MinInt(a, b int) int
- func MinInt32(a, b int32) int32
- func MinLong(a, b int64) int64
- func MinObjectId(a, b bson.ObjectId) bson.ObjectId
- func MinString(a, b string) string
- func MinT(t string, a interface{}, b interface{}) interface{}
- func MinTimestamp(a, b bson.MongoTimestamp) bson.MongoTimestamp
- func MinUInt(a, b uint) uint
- func ParseDate(input string) time.Time
- func ParseDecimal(input string) bson.Decimal128
- func PrintData(data interface{})
- func ReadChannelToNull(ch interface{}) int
- func SafeToBool(value interface{}) bool
- func SafeToDate(value interface{}) time.Time
- func SafeToDecimal(value interface{}) bson.Decimal128
- func SafeToDouble(value interface{}) float64
- func SafeToInt(value interface{}) int
- func SafeToInt32(value interface{}) int32
- func SafeToLong(value interface{}) int64
- func SafeToObjectId(value interface{}) bson.ObjectId
- func SafeToString(value interface{}) string
- func SafeToTimestamp(value interface{}) bson.MongoTimestamp
- func ToDouble(input interface{}) float64
- func ToUInt(input interface{}) uint
- func VersionToString(version ...int) string
- type DecimalProxy
- type Timezone
Constants ¶
const LAST_SUNDAY = -1
LAST_SUNDAY represents last sunday in month.
Variables ¶
This section is empty.
Functions ¶
func CeilDateSeconds ¶
CeilDateSeconds rounds up seconds to whole seconds, minutes, hours, days.
func CeilIn24System ¶
CeilIn24System - 1, 2, 3, 6, 12, 24
func CeilIn60System ¶
CeilIn60System - 1, 2, 5, 10, 15, 30
func CeilWithStep ¶
CeilWithStep - ceil value with given step.
func CmpDecimal ¶
func CmpDecimal(a bson.Decimal128, b bson.Decimal128) int
CmpDecimal compares Decimal.
func CmpDecimalProxy ¶
func CmpDecimalProxy(a DecimalProxy, b DecimalProxy) int
CmpDecimalProxy compares DecimalProxy.
func DataToString ¶
func DataToString(data interface{}) string
DataToString formats structured data to string.
func DecimalToDouble ¶
func DecimalToDouble(input bson.Decimal128) float64
DecimalToDouble or panic.
func DoubleToDecimal ¶
func DoubleToDecimal(input float64) bson.Decimal128
DoubleToDecimal or panic.
func FloorWithStep ¶
FloorWithStep - floor value with given step.
func FromDoubleTo ¶
FromDoubleTo converts float64 to some selected types or panic.
func GetBSONFieldName ¶
GetBSONFieldName gets bson tag name from struct field.
func GetJSONFieldName ¶
GetJSONFieldName gets json tag name from struct field.
func GetYAMLFieldName ¶
GetYAMLFieldName gets yaml tag name from struct field.
func HashData ¶
func HashData(input interface{}) uint32
HashData hash structured data regardless of the order
func InStringSlice ¶
InStringSlice return true if value is in slice.
func MaxDecimal ¶
func MaxDecimal(a, b bson.Decimal128) bson.Decimal128
MaxDecimal gets maximum of two bson.Decimal128 values.
func MaxObjectId ¶
MaxObjectId gets maximum of two ObjectId values.
func MaxT ¶
func MaxT(t string, a interface{}, b interface{}) interface{}
MaxT gets maximum of two values.
func MaxTimestamp ¶
func MaxTimestamp(a, b bson.MongoTimestamp) bson.MongoTimestamp
MaxTimestamp gets maximum of two bson.MongoTimestamp values.
func MinDecimal ¶
func MinDecimal(a, b bson.Decimal128) bson.Decimal128
MinDecimal gets minimum of two bson.Decimal128 values.
func MinObjectId ¶
MinObjectId gets minimum of two ObjectId values.
func MinT ¶
func MinT(t string, a interface{}, b interface{}) interface{}
MinT gets minimum of two values.
func MinTimestamp ¶
func MinTimestamp(a, b bson.MongoTimestamp) bson.MongoTimestamp
MinTimestamp gets minimum of two bson.MongoTimestamp values.
func ReadChannelToNull ¶
func ReadChannelToNull(ch interface{}) int
ReadChannelToNull reads values from channel to null. Useful for testing.
func SafeToBool ¶
func SafeToBool(value interface{}) bool
SafeToBool converts interface to bool or fail.
func SafeToDate ¶
SafeToDate converts interface to time.Time or fail.
func SafeToDecimal ¶
func SafeToDecimal(value interface{}) bson.Decimal128
SafeToDecimal converts interface to decimal or fail.
func SafeToDouble ¶
func SafeToDouble(value interface{}) float64
SafeToDouble converts interface to float64 or fail.
func SafeToInt32 ¶
func SafeToInt32(value interface{}) int32
SafeToInt32 converts interface to int32 or fail.
func SafeToLong ¶
func SafeToLong(value interface{}) int64
SafeToLong converts interface to long or fail.
func SafeToObjectId ¶
SafeToObjectId converts interface to ObjectId or fail.
func SafeToString ¶
func SafeToString(value interface{}) string
SafeToString converts interface to string or fail.
func SafeToTimestamp ¶
func SafeToTimestamp(value interface{}) bson.MongoTimestamp
SafeToTimestamp converts interface to bson.MongoTimestamp or fail.
func ToDouble ¶
func ToDouble(input interface{}) float64
ToDouble converts some selected types to float64 or panic.
func ToUInt ¶
func ToUInt(input interface{}) uint
ToUInt converts some selected types to uint or panic.
func VersionToString ¶
VersionToString converts MongoDB version to string
Types ¶
type DecimalProxy ¶
type DecimalProxy struct {
H, L uint64
}
DecimalProxy serves to circumvent non-exported attributes of bson.Decimal type.
func ToDecimalProxy ¶
func ToDecimalProxy(value bson.Decimal128) DecimalProxy
ToDecimalProxy converts bson.Decimal128 to DecimalProxy.
func (*DecimalProxy) Exponent ¶
func (d *DecimalProxy) Exponent() int
Exponent gets number exponent.
func (*DecimalProxy) Parts ¶
func (d *DecimalProxy) Parts() (uint64, uint64)
Parts gets number parts.
type Timezone ¶
type Timezone struct { TimeZoneChanging bool WinterTimeOffset int WinterTimeStartDate time.Time WinterTimeStartMonth int WinterTimeStartMonthDays int WinterTimeStartSunday int // -1 means last sunday of month SummerTimeOffset int SummerTimeStartDate time.Time SummerTimeStartMonth int SummerTimeStartMonthDays int SummerTimeStartSunday int // -1 means last sunday of month }
Timezone struct represents information about timezone.
func GetTimezone ¶
GetTimezone returns information about given timezone.