Documentation ¶
Overview ¶
Package cast provides easy and safe casting in Go.
Index ¶
- func StringToDate(s string) (time.Time, error)
- func StringToDateInDefaultLocation(s string, location *time.Location) (time.Time, error)
- func ToBool(i any) bool
- func ToBoolE(i any) (bool, error)
- func ToBoolSlice(i any) []bool
- func ToBoolSliceE(i any) ([]bool, error)
- func ToDuration(i any) time.Duration
- func ToDurationE(i any) (d time.Duration, err error)
- func ToDurationSlice(i any) []time.Duration
- func ToDurationSliceE(i any) ([]time.Duration, error)
- func ToFloat32(i any) float32
- func ToFloat32E(i any) (float32, error)
- func ToFloat64(i any) float64
- func ToFloat64E(i any) (float64, error)
- func ToInt(i any) int
- func ToInt16(i any) int16
- func ToInt16E(i any) (int16, error)
- func ToInt32(i any) int32
- func ToInt32E(i any) (int32, error)
- func ToInt64(i any) int64
- func ToInt64E(i any) (int64, error)
- func ToInt8(i any) int8
- func ToInt8E(i any) (int8, error)
- func ToIntE(i any) (int, error)
- func ToIntSlice(i any) []int
- func ToIntSliceE(i any) ([]int, error)
- func ToSlice(i any) []any
- func ToSliceE(i any) ([]any, error)
- func ToString(i any) string
- func ToStringE(i any) (string, error)
- func ToStringMap(i any) map[string]any
- func ToStringMapBool(i any) map[string]bool
- func ToStringMapBoolE(i any) (map[string]bool, error)
- func ToStringMapE(i any) (map[string]any, error)
- func ToStringMapInt(i any) map[string]int
- func ToStringMapInt64(i any) map[string]int64
- func ToStringMapInt64E(i any) (map[string]int64, error)
- func ToStringMapIntE(i any) (map[string]int, error)
- func ToStringMapString(i any) map[string]string
- func ToStringMapStringE(i any) (map[string]string, error)
- func ToStringMapStringSlice(i any) map[string][]string
- func ToStringMapStringSliceE(i any) (map[string][]string, error)
- func ToStringSlice(i any) []string
- func ToStringSliceE(i any) ([]string, error)
- func ToTime(i any) time.Time
- func ToTimeE(i any) (tim time.Time, err error)
- func ToTimeInDefaultLocation(i any, location *time.Location) time.Time
- func ToTimeInDefaultLocationE(i any, location *time.Location) (tim time.Time, err error)
- func ToUint(i any) uint
- func ToUint16(i any) uint16
- func ToUint16E(i any) (uint16, error)
- func ToUint32(i any) uint32
- func ToUint32E(i any) (uint32, error)
- func ToUint64(i any) uint64
- func ToUint64E(i any) (uint64, error)
- func ToUint8(i any) uint8
- func ToUint8E(i any) (uint8, error)
- func ToUintE(i any) (uint, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StringToDate ¶
StringToDate attempts to parse a string into a time.Time type using a predefined list of formats. If no suitable format is found, an error is returned.
func StringToDateInDefaultLocation ¶
StringToDateInDefaultLocation casts an empty interface to a time.Time, interpreting inputs without a timezone to be in the given location, or the local timezone if nil.
func ToBoolSliceE ¶
ToBoolSliceE casts an interface to a []bool type.
func ToDuration ¶
ToDuration casts an interface to a time.Duration type.
func ToDurationE ¶
ToDurationE casts an interface to a time.Duration type.
func ToDurationSlice ¶
ToDurationSlice casts an interface to a []time.Duration type.
func ToDurationSliceE ¶
ToDurationSliceE casts an interface to a []time.Duration type.
func ToFloat32E ¶
ToFloat32E casts an interface to a float32 type.
func ToFloat64E ¶
ToFloat64E casts an interface to a float64 type.
func ToIntSliceE ¶
ToIntSliceE casts an interface to a []int type.
func ToStringMap ¶
ToStringMap casts an interface to a map[string]any type.
func ToStringMapBool ¶
ToStringMapBool casts an interface to a map[string]bool type.
func ToStringMapBoolE ¶
ToStringMapBoolE casts an interface to a map[string]bool type.
func ToStringMapE ¶
ToStringMapE casts an interface to a map[string]any type.
func ToStringMapInt ¶
ToStringMapInt casts an interface to a map[string]int type.
func ToStringMapInt64 ¶
ToStringMapInt64 casts an interface to a map[string]int64 type.
func ToStringMapInt64E ¶
ToStringMapInt64E casts an interface to a map[string]int64{} type.
func ToStringMapIntE ¶
ToStringMapIntE casts an interface to a map[string]int{} type.
func ToStringMapString ¶
ToStringMapString casts an interface to a map[string]string type.
func ToStringMapStringE ¶
ToStringMapStringE casts an interface to a map[string]string type.
func ToStringMapStringSlice ¶
ToStringMapStringSlice casts an interface to a map[string][]string type.
func ToStringMapStringSliceE ¶
ToStringMapStringSliceE casts an interface to a map[string][]string type.
func ToStringSlice ¶
ToStringSlice casts an interface to a []string type.
func ToStringSliceE ¶
ToStringSliceE casts an interface to a []string type.
func ToTimeInDefaultLocation ¶
func ToTimeInDefaultLocationE ¶
ToTimeInDefaultLocationE casts an empty interface to time.Time, interpreting inputs without a timezone to be in the given location, or the local timezone if nil.
Types ¶
This section is empty.