convx

package
v0.0.0-...-e130382 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TimeFormats = []string{
		time.Layout,
		time.ANSIC,
		time.UnixDate,
		time.RubyDate,
		time.RFC822,
		time.RFC822Z,
		time.RFC850,
		time.RFC1123,
		time.RFC1123Z,
		time.RFC3339,
		time.RFC3339Nano,
		time.Kitchen,

		time.Stamp,
		time.StampMilli,
		time.StampMicro,
		time.StampNano,
		time.DateTime,
		time.DateOnly,
		time.TimeOnly,

		"2006-01-02 15:04:05Z07:00",
		"02 Jan 2006",
		"2006-01-02 15:04:05 -07:00",
		"2006-01-02 15:04:05 -0700",
		"2006-01-02T15:04:05",
		"2006-01-02 15:04:05.999999999 -0700 MST",
		"2006-01-02T15:04:05-0700",
		"2006-01-02 15:04:05Z0700",
	}
)

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString converts byte slice to string without a memory allocation. For more details, see https://github.com/golang/go/issues/53003#issuecomment-1140276077.

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes converts string to byte slice without a memory allocation. For more details, see https://github.com/golang/go/issues/53003#issuecomment-1140276077.

func ToBool

func ToBool[E ~bool](o any) E

ToBool casts an interface to a bool type.

func ToBoolE

func ToBoolE[E ~bool](o any) (E, error)

ToBoolE casts an interface to a bool type.

func ToBoolSlice

func ToBoolSlice[S ~[]E, E ~bool](o any) S

ToBoolSlice casts an interface to a []bool type.

func ToBoolSliceE

func ToBoolSliceE[S ~[]E, E ~bool](o any) (S, error)

ToBoolSliceE casts an interface to a []bool type.

func ToDuration

func ToDuration(o any) time.Duration

ToDuration casts an interface to a time.Duration type.

func ToDurationE

func ToDurationE(o any) (time.Duration, error)

ToDurationE casts an interface to a time.Duration type.

func ToDurationSlice

func ToDurationSlice(o any) []time.Duration

ToDurationSlice casts an interface to a []time.Duration type.

func ToDurationSliceE

func ToDurationSliceE(o any) ([]time.Duration, error)

ToDurationSliceE casts an interface to a []time.Duration type.

func ToFloat

func ToFloat[E constraints.Float](o any) E

ToFloat converts an interface to a floating-point type.

func ToFloat32

func ToFloat32(o any) float32

ToFloat32 casts an interface to a float32 type.

func ToFloat32E

func ToFloat32E(o any) (float32, error)

ToFloat32E casts an interface to a float32 type.

func ToFloat32Slice

func ToFloat32Slice(o any) []float32

ToFloat32Slice casts an interface to a float32 slice type.

func ToFloat32SliceE

func ToFloat32SliceE(o any) ([]float32, error)

ToFloat32SliceE casts an interface to a float32 type.

func ToFloat64

func ToFloat64(o any) float64

ToFloat64 casts an interface to a float64 type.

func ToFloat64E

func ToFloat64E(o any) (float64, error)

ToFloat64E casts an interface to a float64 type.

func ToFloat64Slice

func ToFloat64Slice(o any) []float64

ToFloat64Slice casts an interface to a float64 slice type.

func ToFloat64SliceE

func ToFloat64SliceE(o any) ([]float64, error)

ToFloat64SliceE casts an interface to a float64 type.

func ToFloatE

func ToFloatE[E constraints.Float](o any) (E, error)

ToFloatE converts an interface to a floating-point type.

func ToFloatSlice

func ToFloatSlice[S ~[]E, E constraints.Float](o any) S

ToFloatSlice converts an interface to a floating-point slice type.

func ToFloatSliceE

func ToFloatSliceE[S ~[]E, E constraints.Float](o any) (S, error)

ToFloatSliceE converts an interface to a floating-point slice type.

func ToInt

func ToInt(o any) int

ToInt converts an interface to an int type.

func ToInt16

func ToInt16(o any) int16

ToInt16 converts an interface to an int16 type.

func ToInt16E

func ToInt16E(o any) (int16, error)

ToInt16E converts an interface to an int16 type.

func ToInt16Slice

func ToInt16Slice(o any) []int16

ToInt16Slice converts an interface to an int16 type.

func ToInt16SliceE

func ToInt16SliceE(o any) ([]int16, error)

ToInt16SliceE converts an interface to an []int16 type.

func ToInt32

func ToInt32(o any) int32

ToInt32 converts an interface to an int32 type.

func ToInt32E

func ToInt32E(o any) (int32, error)

ToInt32E converts an interface to an int32 type.

func ToInt32Slice

func ToInt32Slice(o any) []int32

ToInt32Slice casts an interface to a []int32 type.

func ToInt32SliceE

func ToInt32SliceE(o any) ([]int32, error)

ToInt32SliceE casts an interface to a []int32 type.

func ToInt64

func ToInt64(o any) int64

ToInt64 converts an interface to an int64 type.

func ToInt64E

func ToInt64E(o any) (int64, error)

ToInt64E converts an interface to an int64 type.

func ToInt64Slice

func ToInt64Slice(o any) []int64

ToInt64Slice casts an interface to a []int64 type.

func ToInt64SliceE

func ToInt64SliceE(o any) ([]int64, error)

ToInt64SliceE casts an interface to a []int64 type.

func ToInt8

func ToInt8(o any) int8

ToInt8 converts an interface to an int8 type.

func ToInt8E

func ToInt8E(o any) (int8, error)

ToInt8E converts an interface to an int8 type.

func ToInt8Slice

func ToInt8Slice(o any) []int8

ToInt8Slice converts an interface to an int8 type.

func ToInt8SliceE

func ToInt8SliceE(o any) ([]int8, error)

ToInt8SliceE converts an interface to an []int8 type.

func ToIntE

func ToIntE(o any) (int, error)

ToIntE converts an interface to an int type.

func ToIntSlice

func ToIntSlice(o any) []int

ToIntSlice casts an interface to a []int type.

func ToIntSliceE

func ToIntSliceE(o any) ([]int, error)

ToIntSliceE casts an interface to a []int type.

func ToSigned

func ToSigned[E constraints.Signed](o any) E

ToSigned converts an interface to a signed integer type.

func ToSignedE

func ToSignedE[E constraints.Signed](o any) (E, error)

ToSignedE converts an interface to a signed integer type.

func ToSignedSlice

func ToSignedSlice[S ~[]E, E constraints.Signed](o any) S

ToSignedSlice converts an interface to a signed integer slice type.

func ToSignedSliceE

func ToSignedSliceE[S ~[]E, E constraints.Signed](o any) (S, error)

ToSignedSliceE converts an interface to a signed integer slice type.

func ToSlice

func ToSlice(o any) []any

ToSlice casts an interface to a []any type.

func ToSliceE

func ToSliceE(o any) ([]any, error)

ToSliceE casts an interface to a []any type.

func ToString

func ToString(o any) string

ToString casts an interface to a string type.

func ToStringE

func ToStringE(o any) (string, error)

ToStringE casts an interface to a string type.

func ToStringMap

func ToStringMap(o any) map[string]any

ToStringMap casts an interface to a map[string]any type.

func ToStringMapBool

func ToStringMapBool(o any) map[string]bool

ToStringMapBool casts an interface to a map[string]bool type.

func ToStringMapBoolE

func ToStringMapBoolE(o any) (map[string]bool, error)

ToStringMapBoolE casts an interface to a map[string]bool type.

func ToStringMapE

func ToStringMapE(o any) (map[string]any, error)

ToStringMapE casts an interface to a map[string]any type.

func ToStringMapInt

func ToStringMapInt(o any) map[string]int

ToStringMapInt casts an interface to a map[string]int type.

func ToStringMapInt64

func ToStringMapInt64(o any) map[string]int64

ToStringMapInt64 casts an interface to a map[string]int64 type.

func ToStringMapInt64E

func ToStringMapInt64E(o any) (map[string]int64, error)

ToStringMapInt64E casts an interface to a map[string]int64{} type.

func ToStringMapIntE

func ToStringMapIntE(o any) (map[string]int, error)

ToStringMapIntE casts an interface to a map[string]int{} type.

func ToStringMapString

func ToStringMapString(o any) map[string]string

ToStringMapString casts an interface to a map[string]string type.

func ToStringMapStringE

func ToStringMapStringE(o any) (map[string]string, error)

ToStringMapStringE casts an interface to a map[string]string type.

func ToStringMapStringSlice

func ToStringMapStringSlice(o any) map[string][]string

ToStringMapStringSlice casts an interface to a map[string][]string type.

func ToStringMapStringSliceE

func ToStringMapStringSliceE(o any) (map[string][]string, error)

ToStringMapStringSliceE casts an interface to a map[string][]string type.

func ToStringSlice

func ToStringSlice(o any) []string

ToStringSlice casts an interface to a []string type.

func ToStringSliceE

func ToStringSliceE(o any) ([]string, error)

ToStringSliceE casts an interface to a []string type.

func ToText

func ToText[E ~string](o any) E

ToText casts an interface to a string type.

func ToTextE

func ToTextE[E ~string](o any) (E, error)

ToTextE casts an interface to a string type.

func ToTextSlice

func ToTextSlice[S ~[]E, E ~string](o any) S

ToTextSlice casts an interface to a []string type.

func ToTextSliceE

func ToTextSliceE[S ~[]E, E ~string](o any) (S, error)

ToTextSliceE casts an interface to a []string type.

func ToTime

func ToTime(o any) time.Time

ToTime casts an interface to a time.Time type.

func ToTimeE

func ToTimeE(o any) (time.Time, error)

ToTimeE casts an interface to a time.Time type.

func ToTimeInLocation

func ToTimeInLocation(o any, location *time.Location) time.Time

ToTimeInLocation casts an empty interface to time.Time,

func ToTimeInLocationE

func ToTimeInLocationE(o any, location *time.Location) (time.Time, error)

ToTimeInLocationE 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 ToUint

func ToUint(o any) uint

ToUint converts an interface to a uint type.

func ToUint16

func ToUint16(o any) uint16

ToUint16 converts an interface to a uint16 type.

func ToUint16E

func ToUint16E(o any) (uint16, error)

ToUint16E converts an interface to a uint16 type.

func ToUint16Slice

func ToUint16Slice(o any) []uint16

ToUint16Slice converts an interface to a []uint16 type.

func ToUint16SliceE

func ToUint16SliceE(o any) ([]uint16, error)

ToUint16SliceE converts an interface to a uint16 type.

func ToUint32

func ToUint32(o any) uint32

ToUint32 converts an interface to a uint32 type.

func ToUint32E

func ToUint32E(o any) (uint32, error)

ToUint32E converts an interface to a uint32 type.

func ToUint32Slice

func ToUint32Slice(o any) []uint32

ToUint32Slice casts an interface to a []uint32 type.

func ToUint32SliceE

func ToUint32SliceE(o any) ([]uint32, error)

ToUint32SliceE casts an interface to a []int32 type.

func ToUint64

func ToUint64(o any) uint64

ToUint64 converts an interface to a uint64 type.

func ToUint64E

func ToUint64E(o any) (uint64, error)

ToUint64E converts an interface to a uint64 type.

func ToUint64Slice

func ToUint64Slice(o any) []uint64

ToUint64Slice casts an interface to a []uint64 type.

func ToUint64SliceE

func ToUint64SliceE(o any) ([]uint64, error)

ToUint64SliceE casts an interface to a []uint64 type.

func ToUint8

func ToUint8(o any) uint8

ToUint8 converts an interface to a uint8 type.

func ToUint8E

func ToUint8E(o any) (uint8, error)

ToUint8E converts an interface to a uint type.

func ToUint8Slice

func ToUint8Slice(o any) []uint8

ToUint8Slice converts an interface to a []uint8 type.

func ToUint8SliceE

func ToUint8SliceE(o any) ([]uint8, error)

ToUint8SliceE converts an interface to a uint type.

func ToUintE

func ToUintE(o any) (uint, error)

ToUintE converts an interface to a uint type.

func ToUintSlice

func ToUintSlice(o any) []uint

ToUintSlice casts an interface to a []uint type.

func ToUintSliceE

func ToUintSliceE(a any) ([]uint, error)

ToUintSliceE casts an interface to a []uint type.

func ToUnsigned

func ToUnsigned[N constraints.Unsigned](o any) N

ToUnsigned converts an interface to a unsigned integer type.

func ToUnsignedE

func ToUnsignedE[E constraints.Unsigned](o any) (E, error)

ToUnsignedE converts an interface to a unsigned integer type.

func ToUnsignedSlice

func ToUnsignedSlice[S ~[]E, E constraints.Unsigned](o any) S

ToUnsignedSlice converts an interface to an unsigned integer slice type.

func ToUnsignedSliceE

func ToUnsignedSliceE[S ~[]E, E constraints.Unsigned](o any) (S, error)

ToUnsignedSliceE converts an interface to an unsigned integer slice type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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