Documentation
¶
Overview ¶
Package basic implements scalar conversions used by mconv.
Applications should normally import github.com/graingo/mconv and use its root-level functions. This package remains public for v1 compatibility.
Index ¶
- func ToBool(value interface{}) bool
- func ToBoolE(value interface{}) (bool, error)
- func ToComplex64(value interface{}) complex64
- func ToComplex64E(value interface{}) (complex64, error)
- func ToComplex128(value interface{}) complex128
- func ToComplex128E(value interface{}) (complex128, error)
- func ToDuration(value interface{}) time.Duration
- func ToDurationE(value interface{}) (time.Duration, error)
- func ToFloat32(value interface{}) float32
- func ToFloat32E(value interface{}) (float32, error)
- func ToFloat64(value interface{}) float64
- func ToFloat64E(value interface{}) (float64, error)
- func ToInt(value interface{}) int
- func ToInt8(value interface{}) int8
- func ToInt8E(value interface{}) (int8, error)
- func ToInt16(value interface{}) int16
- func ToInt16E(value interface{}) (int16, error)
- func ToInt32(value interface{}) int32
- func ToInt32E(value interface{}) (int32, error)
- func ToInt64(value interface{}) int64
- func ToInt64E(value interface{}) (int64, error)
- func ToIntE(value interface{}) (int, error)
- func ToString(value interface{}) string
- func ToStringE(value interface{}) (string, error)
- func ToTime(value interface{}, formats ...string) time.Time
- func ToTimeE(value interface{}, formats ...string) (time.Time, error)
- func ToUint(value interface{}) uint
- func ToUint8(value interface{}) uint8
- func ToUint8E(value interface{}) (uint8, error)
- func ToUint16(value interface{}) uint16
- func ToUint16E(value interface{}) (uint16, error)
- func ToUint32(value interface{}) uint32
- func ToUint32E(value interface{}) (uint32, error)
- func ToUint64(value interface{}) uint64
- func ToUint64E(value interface{}) (uint64, error)
- func ToUintE(value interface{}) (uint, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToComplex64 ¶
func ToComplex64(value interface{}) complex64
ToComplex64 converts any type to complex64.
func ToComplex64E ¶
ToComplex64E converts any type to complex64 with error.
func ToComplex128 ¶
func ToComplex128(value interface{}) complex128
ToComplex128 converts any type to complex128.
func ToComplex128E ¶
func ToComplex128E(value interface{}) (complex128, error)
ToComplex128E converts any type to complex128 with error.
func ToDuration ¶ added in v0.1.2
ToDuration converts any type to time.Duration.
func ToDurationE ¶ added in v0.1.2
ToDurationE converts any type to time.Duration with error.
func ToFloat32E ¶
ToFloat32E converts any type to float32 with error.
func ToFloat64E ¶
ToFloat64E converts any type to float64 with error.
func ToInt ¶
func ToInt(value interface{}) int
ToInt converts value to int and returns zero when conversion fails.
func ToInt8 ¶
func ToInt8(value interface{}) int8
ToInt8 converts value to int8 and returns zero when conversion fails.
func ToInt16 ¶
func ToInt16(value interface{}) int16
ToInt16 converts value to int16 and returns zero when conversion fails.
func ToInt32 ¶
func ToInt32(value interface{}) int32
ToInt32 converts value to int32 and returns zero when conversion fails.
func ToInt64 ¶
func ToInt64(value interface{}) int64
ToInt64 converts value to int64 and returns zero when conversion fails.
func ToTime ¶
ToTime converts any type to time.Time. When value is a string, it will be parsed using the formats.
func ToTimeE ¶
ToTimeE converts any type to time.Time with error. When value is a string, it will be parsed using the formats.
func ToUint ¶
func ToUint(value interface{}) uint
ToUint converts value to uint and returns zero when conversion fails.
func ToUint8 ¶
func ToUint8(value interface{}) uint8
ToUint8 converts value to uint8 and returns zero when conversion fails.
func ToUint16 ¶
func ToUint16(value interface{}) uint16
ToUint16 converts value to uint16 and returns zero when conversion fails.
func ToUint32 ¶
func ToUint32(value interface{}) uint32
ToUint32 converts value to uint32 and returns zero when conversion fails.
func ToUint64 ¶
func ToUint64(value interface{}) uint64
ToUint64 converts value to uint64 and returns zero when conversion fails.
Types ¶
This section is empty.