Documentation ¶
Overview ¶
Package conv provides handy conversion functions.
Index ¶
- func DaysSince(t time.Time) int
- func DefaultMaxFloat(val, def, max float64) float64
- func DefaultMaxInt(val, def, max int) int
- func DiffInDays(a, b time.Time) int
- func Env(key string) string
- func FToC(f float64) float64
- func FeetToMeters(f float64) float64
- func FirstNonEmptyString(list ...string) string
- func FirstNonZeroFloat(list ...float64) float64
- func FirstNonZeroInt(list ...int) int
- func FirstPositiveFloat(list ...float64) float64
- func FirstPositiveInt(list ...int) int
- func FuzzInt(input int, min, max int) int
- func IsNil(i interface{}) (isNil bool)
- func MaxFloat(a, b float64) float64
- func MaxInt(a, b int) int
- func MilesToKm(m float64) float64
- func MinFloat(a, b float64) float64
- func MinInt(a, b int) int
- func MinMaxFloat(val, min, max float64) float64
- func MinMaxInt(val, min, max int) int
- func ParseTime(input string) (time.Time, error)
- func QuoteString(s string) string
- func RatioPercent(a, b float64) float64
- func RelativeTime(dur time.Duration) string
- func Round(num float64) int
- func ToFixed(num float64, precision int) float64
- func ZeroIfNilFloat(in *float64) float64
- func ZeroIfNilInt(in *int) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultMaxFloat ¶ added in v1.0.84
func DefaultMaxInt ¶ added in v1.0.84
DefaultMaxInt returns the default if val is < 0, max if val is > max.
func DiffInDays ¶ added in v1.0.82
func FirstNonEmptyString ¶ added in v1.1.3
func FirstNonZeroFloat ¶ added in v1.1.34
func FirstNonZeroInt ¶ added in v1.1.4
func FirstPositiveFloat ¶ added in v1.1.34
func FirstPositiveInt ¶ added in v1.1.34
func FuzzInt ¶ added in v1.1.39
FuzzInt adds or subtracts a certain percentage from the input. Ex: FuzzInt(100, 1, 100) will have an output range between 0 and 100 Ex: FuzzInt(100, 1, 10) will have an output range between 90 and 110, and will add/remove at least 1% Ex: FuzzInt(100, 8, 10) will have an output range between 90 and 110, and will add/remove at least 8%
func IsNil ¶ added in v1.1.18
func IsNil(i interface{}) (isNil bool)
Returns true if the given interface is nil.
func MinMaxFloat ¶ added in v1.0.82
func ParseTime ¶ added in v1.0.13
ParseTime attempts to extract a valid time.Time from an input string. We prefer RFC3999. Fallback should match MSSQL's CURRENT_TIMESTAMP.
func QuoteString ¶ added in v1.0.86
QuoteString adds quotes to a string.
func RatioPercent ¶ added in v1.0.82
func RelativeTime ¶
RelativeTime takes a time.Duration and returns the largest denomination relative time. eg. 1y for a duration over 400 days.
func ZeroIfNilFloat ¶ added in v1.1.37
func ZeroIfNilInt ¶ added in v1.1.37
Types ¶
This section is empty.