cast

package
v0.0.0-...-c18a219 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 9 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(buf []byte) string

BytesToString converts []byte to string with zero-copy

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes converts string to []byte with zero-copy

func StringToInt32Slice

func StringToInt32Slice(s, sep string) []int32

StringToInt32Slice converts string to []int32

func StringToInt64Slice

func StringToInt64Slice(s, sep string) []int64

StringToInt64Slice converts string to []int64

func StringToIntSlice

func StringToIntSlice(s, sep string) []int

StringToIntSlice converts string to []int

func StringToTime

func StringToTime(s string) (t time.Time, e error)

StringToTime casts an empty interface to a time.Time.

func StringToType

func StringToType(s string, p reflect.Type) interface{}

TODO: refactor

func ToBool

func ToBool(i interface{}, d ...bool) bool

func ToDuration

func ToDuration(i interface{}, d ...time.Duration) time.Duration

func ToFloat32

func ToFloat32(i interface{}, d ...float32) float32

func ToFloat64

func ToFloat64(i interface{}, d ...float64) float64

func ToInt

func ToInt(i interface{}, d ...int) int

func ToInt16

func ToInt16(i interface{}, d ...int16) int16

func ToInt32

func ToInt32(i interface{}, d ...int32) int32

func ToInt32Slice

func ToInt32Slice(i interface{}, d ...[]int32) (r []int32)

ToInt32Slice casts an empty interface to []int32.

func ToInt64

func ToInt64(i interface{}, d ...int64) int64

func ToInt64Slice

func ToInt64Slice(i interface{}, d ...[]int64) (r []int64)

ToInt64Slice casts an empty interface to []int64.

func ToInt8

func ToInt8(i interface{}, d ...int8) int8

func ToString

func ToString(i interface{}) string

ToString casts an empty interface to a string.

func ToTime

func ToTime(i interface{}, d ...time.Time) time.Time

func ToUint

func ToUint(i interface{}, d ...uint) uint

func ToUint16

func ToUint16(i interface{}, d ...uint16) uint16

func ToUint32

func ToUint32(i interface{}, d ...uint32) uint32

func ToUint64

func ToUint64(i interface{}, d ...uint64) uint64

func ToUint8

func ToUint8(i interface{}, d ...uint8) uint8

func TryToBool

func TryToBool(i interface{}) (b bool, err error)

TryToBool casts an empty interface to a bool.

func TryToDuration

func TryToDuration(i interface{}) (d time.Duration, err error)

TryToDuration casts an empty interface to time.Duration.

func TryToFloat32

func TryToFloat32(i interface{}) (r float32, err error)

TryToFloat32 casts an empty interface to a float32.

func TryToFloat64

func TryToFloat64(i interface{}) (r float64, err error)

TryToFloat64 casts an empty interface to a float64.

func TryToInt

func TryToInt(i interface{}) (r int, err error)

TryToInt casts an empty interface to an int.

func TryToInt16

func TryToInt16(i interface{}) (r int16, err error)

TryToInt16 casts an empty interface to an int16.

func TryToInt32

func TryToInt32(i interface{}) (r int32, err error)

TryToInt32 casts an empty interface to an int32.

func TryToInt32Slice

func TryToInt32Slice(i interface{}) (r []int32, err error)

TryToInt32Slice casts an empty interface to []int32.

func TryToInt64

func TryToInt64(i interface{}) (r int64, err error)

TryToInt64 casts an empty interface to an int64.

func TryToInt64Slice

func TryToInt64Slice(i interface{}) (r []int64, err error)

TryToInt64Slice casts an empty interface to []int64.

func TryToInt8

func TryToInt8(i interface{}) (r int8, err error)

TryToInt8 casts an empty interface to an int8.

func TryToSlice

func TryToSlice(i interface{}, t reflect.Type) (interface{}, error)

func TryToSliceValue

func TryToSliceValue(i interface{}, t reflect.Type) (slice reflect.Value, err error)

TryToSliceValue cast interface value to a slice. Argument t is element type of slice.

func TryToTime

func TryToTime(i interface{}) (t time.Time, err error)

TryToTime casts an empty interface to time.Time.

func TryToUint

func TryToUint(i interface{}) (r uint, err error)

TryToUint casts an empty interface to a uint.

func TryToUint16

func TryToUint16(i interface{}) (r uint16, err error)

TryToUint16 casts an empty interface to a uint16.

func TryToUint32

func TryToUint32(i interface{}) (r uint32, err error)

TryToUint32 casts an empty interface to a uint32.

func TryToUint64

func TryToUint64(i interface{}) (r uint64, err error)

TryToUint64 casts an empty interface to a uint64.

func TryToUint8

func TryToUint8(i interface{}) (r uint8, err error)

TryToUint8 casts an empty interface to an uint8.

func TryToValue

func TryToValue(i interface{}, t reflect.Type) (v reflect.Value, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL