safecast

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 5 Imported by: 10

Documentation

Index

Constants

View Source
const (
	ISO8601DateLayout     = "2006-01-02"
	ISO8601TimeLayout     = "15:04:05"
	ISO860TimestampLayout = "2006-01-02T15:04:05"
	DateTime              = "2006-01-02 15:04:05"
	DateTimeZ             = "2006-01-02 15:04:05 MST"
	DateTimeNZ            = "2006-01-02 15:04:05 -0700"
)

Variables

View Source
var ErrCast = errors.New("cast error")

SupportedTimeLayouts is a list of supported time layouts.

Functions

func FromBool added in v1.1.0

func FromBool(from bool, to any) error

FromBool casts an interface to a bool type.

func FromFloat32 added in v1.1.0

func FromFloat32(from float32, to any) error

FromFloat32 casts an interface to an float32 type.

func FromFloat64 added in v1.1.0

func FromFloat64(from float64, to any) error

FromFloat64 casts an interface to an float64 type.

func FromInt

func FromInt(from int, to any) error

FromInt casts an interface to an int type.

func FromInt16

func FromInt16(from int16, to any) error

FromInt16 casts an interface to an int16 type.

func FromInt32

func FromInt32(from int32, to any) error

FromInt32 casts an interface to an int32 type.

func FromInt64

func FromInt64(from int64, to any) error

FromInt64 casts an interface to an int64 type.

func FromInt8

func FromInt8(from int8, to any) error

FromInt8 casts an interface to an int8 type.

func FromString added in v1.1.0

func FromString(from string, to any) error

FromString casts an interface to a string type.

func FromUint

func FromUint(from uint, to any) error

FromUint casts an interface to an uint type.

func FromUint16

func FromUint16(from uint16, to any) error

FromUint16 casts an interface to an uint16 type.

func FromUint32

func FromUint32(from uint32, to any) error

FromUint32 casts an interface to an uint32 type.

func FromUint64

func FromUint64(from uint64, to any) error

FromUint64 casts an interface to an uint64 type.

func FromUint8

func FromUint8(from uint8, to any) error

FromUint8 casts an interface to an uint8 type.

func ToBool added in v1.2.0

func ToBool(from any, to *bool) error

ToBool casts an interface to a bool type.

func ToFloat32 added in v1.2.0

func ToFloat32(from any, to *float32) error

ToFloat32 casts an interface to an float64 type.

func ToFloat64 added in v1.2.0

func ToFloat64(from any, to *float64) error

ToFloat64 casts an interface to an float64 type.

func ToInt added in v1.2.0

func ToInt(from any, to *int) error

ToInt casts an interface to an int type.

func ToInt16 added in v1.2.0

func ToInt16(from any, to *int16) error

ToInt16 casts an interface to an int16 type.

func ToInt32 added in v1.2.0

func ToInt32(from any, to *int32) error

ToInt32 casts an interface to an int32 type.

func ToInt64 added in v1.2.0

func ToInt64(from any, to *int64) error

ToInt64 casts an interface to an int64 type.

func ToInt8 added in v1.2.0

func ToInt8(from any, to *int8) error

ToInt8 casts an interface to an int8 type.

func ToString added in v1.2.0

func ToString(from any, to *string) error

ToString casts an interface to a string type.

func ToTime added in v1.2.1

func ToTime(from any, to *time.Time, layouts ...string) error

ToTime casts an interface to a time.Time.

func ToUint added in v1.2.0

func ToUint(from any, to *uint) error

ToUint casts an interface to an uint type.

func ToUint16 added in v1.2.0

func ToUint16(from any, to *uint16) error

ToUint16 casts an interface to an uint16 type.

func ToUint32 added in v1.2.0

func ToUint32(from any, to *uint32) error

ToUint32 casts an interface to an uint32 type.

func ToUint64 added in v1.2.0

func ToUint64(from any, to *uint64) error

ToUint64 casts an interface to an uint64 type.

func ToUint8 added in v1.2.0

func ToUint8(from any, to *uint8) error

ToUint8 casts an interface to an uint8 type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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