Documentation
¶
Overview ¶
Package cast provides many conversion functions between types.
Index ¶
- Variables
- func BoolPtr(s bool) *bool
- func BytesToString(b []byte) string
- func Float32Ptr(s float32) *float32
- func Float64Ptr(s float64) *float64
- func HexDigitToInt(c byte) int
- func Int16Ptr(s int16) *int16
- func Int32Ptr(s int32) *int32
- func Int64Ptr(s int64) *int64
- func Int8Ptr(s int8) *int8
- func IntPtr(s int) *int
- func IsHexDigit(c byte) bool
- func StringPtr(s string) *string
- func StringToBytes(s string) []byte
- func ToBool(i interface{}) bool
- func ToBoolE(i interface{}) (bool, error)
- func ToDuration(i interface{}, unit ...time.Duration) time.Duration
- func ToDurationE(i interface{}, unit ...time.Duration) (time.Duration, error)
- func ToFloat32(i interface{}) float32
- func ToFloat64(i interface{}) float64
- func ToFloat64E(i interface{}) (float64, error)
- func ToInt(i interface{}) int
- func ToInt16(i interface{}) int16
- func ToInt32(i interface{}) int32
- func ToInt64(i interface{}) int64
- func ToInt64E(i interface{}) (int64, error)
- func ToInt8(i interface{}) int8
- func ToString(i interface{}) string
- func ToStringE(i interface{}) (string, error)
- func ToTime(i interface{}, format ...string) time.Time
- func ToTimeE(i interface{}, format ...string) (time.Time, error)
- func ToUint(i interface{}) uint
- func ToUint16(i interface{}) uint16
- func ToUint32(i interface{}) uint32
- func ToUint64(i interface{}) uint64
- func ToUint64E(i interface{}) (uint64, error)
- func ToUint8(i interface{}) uint8
- func Uint16Ptr(s uint16) *uint16
- func Uint32Ptr(s uint32) *uint32
- func Uint64Ptr(s uint64) *uint64
- func Uint8Ptr(s uint8) *uint8
- func UintPtr(s uint) *uint
- type ConversionArg
Constants ¶
This section is empty.
Variables ¶
var ( FAST = &fastEncoding{} JSON = &jsonEncoding{} )
Functions ¶
func BytesToString ¶ added in v1.1.3
BytesToString converts byte slice to string without memory allocation.
func Float32Ptr ¶ added in v1.1.3
func Float64Ptr ¶ added in v1.1.3
func IsHexDigit ¶
IsHexDigit returns whether the character is a valid hexadecimal character.
func StringToBytes ¶ added in v1.1.3
StringToBytes converts string to byte slice without memory allocation.
func ToBool ¶
func ToBool(i interface{}) bool
ToBool casts an interface{} to a bool. When type is clear, it is recommended to use standard library functions.
func ToBoolE ¶
ToBoolE casts an interface{} to a bool. When type is clear, it is recommended to use standard library functions.
func ToDuration ¶
ToDuration casts an interface{} to a time.Duration. When type is clear, it is recommended to use standard library functions.
func ToDurationE ¶
ToDurationE casts an interface{} to a time.Duration. When type is clear, it is recommended to use standard library functions.
func ToFloat32 ¶
func ToFloat32(i interface{}) float32
ToFloat32 casts an interface{} to a float32. When type is clear, it is recommended to use standard library functions.
func ToFloat64 ¶
func ToFloat64(i interface{}) float64
ToFloat64 casts an interface{} to a float64. When type is clear, it is recommended to use standard library functions.
func ToFloat64E ¶
ToFloat64E casts an interface{} to a float64. When type is clear, it is recommended to use standard library functions.
func ToInt ¶
func ToInt(i interface{}) int
ToInt casts an interface{} to an int. When type is clear, it is recommended to use standard library functions.
func ToInt16 ¶
func ToInt16(i interface{}) int16
ToInt16 casts an interface{} to an int16. When type is clear, it is recommended to use standard library functions.
func ToInt32 ¶
func ToInt32(i interface{}) int32
ToInt32 casts an interface{} to an int32. When type is clear, it is recommended to use standard library functions.
func ToInt64 ¶
func ToInt64(i interface{}) int64
ToInt64 casts an interface{} to an int64. When type is clear, it is recommended to use standard library functions.
func ToInt64E ¶
ToInt64E casts an interface{} to an int64. When type is clear, it is recommended to use standard library functions.
func ToInt8 ¶
func ToInt8(i interface{}) int8
ToInt8 casts an interface{} to an int8. When type is clear, it is recommended to use standard library functions.
func ToString ¶
func ToString(i interface{}) string
ToString casts an interface{} to a string. When type is clear, it is recommended to use standard library functions.
func ToStringE ¶
ToStringE casts an interface{} to a string. When type is clear, it is recommended to use standard library functions.
func ToTime ¶
ToTime casts an interface{} to a time.Time. When type is clear, it is recommended to use standard library functions.
func ToTimeE ¶
ToTimeE casts an interface{} to a time.Time. When type is clear, it is recommended to use standard library functions.
func ToUint ¶
func ToUint(i interface{}) uint
ToUint casts an interface{} to an uint. When type is clear, it is recommended to use standard library functions.
func ToUint16 ¶
func ToUint16(i interface{}) uint16
ToUint16 casts an interface{} to an uint16. When type is clear, it is recommended to use standard library functions.
func ToUint32 ¶
func ToUint32(i interface{}) uint32
ToUint32 casts an interface{} to an uint32. When type is clear, it is recommended to use standard library functions.
func ToUint64 ¶
func ToUint64(i interface{}) uint64
ToUint64 casts an interface{} to an uint64. When type is clear, it is recommended to use standard library functions.
func ToUint64E ¶
ToUint64E casts an interface{} to an uint64. When type is clear, it is recommended to use standard library functions.
Types ¶
type ConversionArg ¶ added in v1.1.3
type ConversionArg struct {
DeepCopy bool
}