Documentation ¶
Overview ¶
Package cast provides easy and safe casting in Go.
Index ¶
- func Bool(i interface{}) bool
- func BoolE(i interface{}) (bool, error)
- func BoolSlice(i interface{}) []bool
- func BoolSliceE(i interface{}) ([]bool, error)
- func Duration(i interface{}) time.Duration
- func DurationE(i interface{}) (d time.Duration, err error)
- func DurationSlice(i interface{}) []time.Duration
- func DurationSliceE(i interface{}) ([]time.Duration, error)
- func Float32(i interface{}) float32
- func Float32E(i interface{}) (float32, error)
- func Float64(i interface{}) float64
- func Float64E(i interface{}) (float64, error)
- func Int(i interface{}) int
- func Int16(i interface{}) int16
- func Int16E(i interface{}) (int16, error)
- func Int32(i interface{}) int32
- func Int32E(i interface{}) (int32, error)
- func Int64(i interface{}) int64
- func Int64E(i interface{}) (int64, error)
- func Int8(i interface{}) int8
- func Int8E(i interface{}) (int8, error)
- func IntE(i interface{}) (int, error)
- func IntSlice(i interface{}) []int
- func IntSliceE(i interface{}) ([]int, error)
- func String(i interface{}) string
- func StringE(i interface{}) (string, error)
- func StringMap(i interface{}) map[string]interface{}
- func StringMapBool(i interface{}) map[string]bool
- func StringMapBoolE(i interface{}) (map[string]bool, error)
- func StringMapE(i interface{}) (map[string]interface{}, error)
- func StringMapInt(i interface{}) map[string]int
- func StringMapInt64(i interface{}) map[string]int64
- func StringMapInt64E(i interface{}) (map[string]int64, error)
- func StringMapIntE(i interface{}) (map[string]int, error)
- func StringMapString(i interface{}) map[string]string
- func StringMapStringE(i interface{}) (map[string]string, error)
- func StringMapStringSlice(i interface{}) map[string][]string
- func StringMapStringSliceE(i interface{}) (map[string][]string, error)
- func StringSlice(i interface{}) []string
- func StringSliceE(i interface{}) ([]string, error)
- func StringToDate(s string) (time.Time, error)
- func StringToDateInDefaultLocation(s string, location *time.Location) (time.Time, error)
- func Time(i interface{}) time.Time
- func TimeE(i interface{}) (tim time.Time, err error)
- func TimeInDefaultLocation(i interface{}, location *time.Location) time.Time
- func TimeInDefaultLocationE(i interface{}, location *time.Location) (tim time.Time, err error)
- func ToSlice(i interface{}) []interface{}
- func ToSliceE(i interface{}) ([]interface{}, error)
- func Uint(i interface{}) uint
- func Uint16(i interface{}) uint16
- func Uint16E(i interface{}) (uint16, error)
- func Uint32(i interface{}) uint32
- func Uint32E(i interface{}) (uint32, error)
- func Uint64(i interface{}) uint64
- func Uint64E(i interface{}) (uint64, error)
- func Uint8(i interface{}) uint8
- func Uint8E(i interface{}) (uint8, error)
- func UintE(i interface{}) (uint, error)
- type Value
- func (v *Value) Any() any
- func (v *Value) Bool() (i bool)
- func (v *Value) BoolE() (b bool, e error)
- func (v *Value) Float() (i float64)
- func (v *Value) Float32() (i float32)
- func (v *Value) Float32E() (f float32, err error)
- func (v *Value) FloatE() (f float64, e error)
- func (v *Value) Int() int
- func (v *Value) Int16() (i int16)
- func (v *Value) Int16E() (i16 int16, e error)
- func (v *Value) Int32() (i int32)
- func (v *Value) Int32E() (i32 int32, e error)
- func (v *Value) Int64() (i int64)
- func (v *Value) Int64E() (i64 int64, e error)
- func (v *Value) Int8() int8
- func (v *Value) Int8E() (i8 int8, e error)
- func (v *Value) Int8s() (i Values[int8])
- func (s *Value) Int8sE() (Values[int8], error)
- func (v *Value) IntE() (i int, e error)
- func (v *Value) Ints() (i []int)
- func (s *Value) IntsE() ([]int, error)
- func (s *Value) IsNil() bool
- func (v *Value) Split(sep string) Values[string]
- func (v *Value) String() (s string)
- func (v *Value) Uint16() (i uint16)
- func (v *Value) Uint16E() (u16 uint16, e error)
- func (v *Value) Uint32() (i uint32)
- func (v *Value) Uint32E() (u32 uint32, e error)
- func (v *Value) Uint64() (i uint64)
- func (v *Value) Uint64E() (u64 uint64, e error)
- func (v *Value) Uint8() (i uint8)
- func (v *Value) Uint8E() (u8 uint8, e error)
- func (v *Value) VInts() (i Values[int])
- type ValueM
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolSlice ¶
func BoolSlice(i interface{}) []bool
BoolSlice casts an interface to a []bool type.
func BoolSliceE ¶
BoolSliceE casts an interface to a []bool type.
func DurationSlice ¶
DurationSlice casts an interface to a []time.Duration type.
func DurationSliceE ¶
DurationSliceE casts an interface to a []time.Duration type.
func StringMap ¶
func StringMap(i interface{}) map[string]interface{}
StringMap casts an interface to a map[string]interface{} type.
func StringMapBool ¶
StringMapBool casts an interface to a map[string]bool type.
func StringMapBoolE ¶
StringMapBoolE casts an interface to a map[string]bool type.
func StringMapE ¶
StringMapE casts an interface to a map[string]interface{} type.
func StringMapInt ¶
StringMapInt casts an interface to a map[string]int type.
func StringMapInt64 ¶
StringMapInt64 casts an interface to a map[string]int64 type.
func StringMapInt64E ¶
StringMapInt64E casts an interface to a map[string]int64{} type.
func StringMapIntE ¶
StringMapIntE casts an interface to a map[string]int{} type.
func StringMapString ¶
StringMapString casts an interface to a map[string]string type.
func StringMapStringE ¶
StringMapStringE casts an interface to a map[string]string type.
func StringMapStringSlice ¶
StringMapStringSlice casts an interface to a map[string][]string type.
func StringMapStringSliceE ¶
StringMapStringSliceE casts an interface to a map[string][]string type.
func StringSlice ¶
func StringSlice(i interface{}) []string
StringSlice casts an interface to a []string type.
func StringSliceE ¶
StringSliceE casts an interface to a []string type.
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 TimeInDefaultLocation ¶
func TimeInDefaultLocationE ¶
TimeInDefaultLocationE casts an empty interface to time.Time, interpreting inputs without a timezone to be in the given location, or the local timezone if nil.
func ToSlice ¶
func ToSlice(i interface{}) []interface{}
ToSlice casts an interface to a []interface{} type.
func ToSliceE ¶
func ToSliceE(i interface{}) ([]interface{}, error)
ToSliceE casts an interface to a []interface{} type.
Types ¶
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
type ValueM ¶
type ValueM[K comparable, T any] map[K]T
func Vm ¶
func Vm[K comparable, T any](v map[K]T) ValueM[K, T]