Documentation ¶
Overview ¶
Package conv contains functions that help converting data between different types
Index ¶
- func AnyToListMapStringAny(v any) ([]map[string]any, error)
- func AnyToMapStringAny(v any) (map[string]any, error)
- func Bool(in string) bool
- func Dict(v ...interface{}) (map[string]interface{}, error)
- func Has(in interface{}, key interface{}) bool
- func Join(in interface{}, sep string) (out string, err error)
- func MustAtoi(s string) int
- func MustParseFloat(s string, bitSize int) float64
- func MustParseInt(s string, base, bitSize int) int64
- func MustParseUint(s string, base, bitSize int) uint64
- func Slice(args ...interface{}) []interface{}
- func ToBool(in interface{}) bool
- func ToBools(in ...interface{}) []bool
- func ToFloat64(v interface{}) float64
- func ToFloat64s(in ...interface{}) []float64
- func ToInt(in interface{}) int
- func ToInt64(v interface{}) int64
- func ToInt64s(in ...interface{}) []int64
- func ToInts(in ...interface{}) []int
- func ToString(in interface{}) string
- func ToStrings(in ...interface{}) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyToListMapStringAny ¶ added in v3.21.0
func Bool ¶
Bool converts a string to a boolean value, using strconv.ParseBool under the covers. Possible true values are: 1, t, T, TRUE, true, True All other values are considered false.
See ToBool also for a more flexible version. Deprecated: use ToBool instead
func Dict ¶
Dict is a convenience function that creates a map with string keys. Provide arguments as key/value pairs. If an odd number of arguments is provided, the last is used as the key, and an empty string is set as the value. All keys are converted to strings, regardless of input type.
func Has ¶
func Has(in interface{}, key interface{}) bool
Has determines whether or not a given object has a property with the given key
func Join ¶
Join concatenates the elements of a to create a single string. The separator string sep is placed between elements in the resulting string.
This is functionally identical to strings.Join, except that each element is coerced to a string first
func MustParseFloat ¶
MustParseFloat - wrapper for strconv.ParseFloat that returns 0 in the case of error
func MustParseInt ¶
MustParseInt - wrapper for strconv.ParseInt that returns 0 in the case of error
func MustParseUint ¶
MustParseUint - wrapper for strconv.ParseUint that returns 0 in the case of error
func Slice ¶
func Slice(args ...interface{}) []interface{}
Slice creates a slice from a bunch of arguments
func ToBool ¶
func ToBool(in interface{}) bool
ToBool converts an arbitrary input into a boolean. Possible non-boolean true values are: 1 or the strings "t", "true", or "yes" (any capitalizations) All other values are considered false.
func ToFloat64 ¶
func ToFloat64(v interface{}) float64
ToFloat64 - convert input to a float64, if convertible. Otherwise, returns 0.
Types ¶
This section is empty.