gcast

package module
Version: v0.0.0-...-3283c3d Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: MIT Imports: 7 Imported by: 0

README

gcast

参考 spf13/cast 编写的一个用于快速类型转换(赋值)的一个工具库

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnaddressable unaddressable val
	ErrUnaddressable = errors.New("val must be addressable")
	// ErrNotPointer pinter val
	ErrNotPointer = errors.New("val must be a pointer")
)

Functions

func Decode

func Decode(src interface{}, dst interface{}) error

Decode decode interface into struct

func MustToBool

func MustToBool(i interface{}) bool

MustToBool casts an empty interface to bool ignoring error

func MustToDuration

func MustToDuration(i interface{}) time.Duration

MustToDuration casts an empty interface to duration ignoring error

func MustToFloat64

func MustToFloat64(i interface{}) float64

MustToFloat64 casts an empty interface to float64 ignoring error

func MustToInt

func MustToInt(i interface{}) int

MustToInt casts an empty interface to int ignoring error

func MustToInt64

func MustToInt64(i interface{}) int64

MustToInt64 casts an empty interface to int64 ignoring error

func MustToIntSlice

func MustToIntSlice(i interface{}) []int

MustToIntSlice casts an empty interface to []int ignoring error

func MustToSlice

func MustToSlice(i interface{}) []interface{}

MustToSlice casts an empty interface []interface ignoring error

func MustToSliceStringMap

func MustToSliceStringMap(i interface{}) []map[string]interface{}

MustToSliceStringMap casts an empty interface to []map[string]interface{} ignoring error

func MustToString

func MustToString(i interface{}) string

MustToString casts an empty interface to string ignoring error

func MustToStringMap

func MustToStringMap(i interface{}) map[string]interface{}

MustToStringMap casts an empty interface to string map ignoring error

func MustToStringMapBool

func MustToStringMapBool(i interface{}) map[string]bool

MustToStringMapBool casts an empty interface to map[string]bool ignoring error

func MustToStringMapString

func MustToStringMapString(i interface{}) map[string]string

MustToStringMapString casts an empty interface to map[string]string ignoring error

func MustToStringMapStringSlice

func MustToStringMapStringSlice(i interface{}) map[string][]string

MustToStringMapStringSlice casts an empty interface to map[string][]string ignoring error

func MustToStringSlice

func MustToStringSlice(i interface{}) []string

MustToStringSlice casts an empty interface to []string ignoring error

func MustToTime

func MustToTime(i interface{}) time.Time

MustToTime casts an empty interface to time ignoring error

func StringToDate

func StringToDate(s string) (time.Time, error)

StringToDate casts an empty interface to a time.Time.

func ToBool

func ToBool(i interface{}) (bool, error)

ToBool casts an empty interface to a bool.

func ToDuration

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

ToDuration casts an empty interface to time.Duration.

func ToFloat64

func ToFloat64(i interface{}) (float64, error)

ToFloat64 casts an empty interface to a float64.

func ToInt

func ToInt(i interface{}) (int, error)

ToInt casts an empty interface to an int.

func ToInt64

func ToInt64(i interface{}) (int64, error)

ToInt64 casts an empty interface to an int64.

func ToIntSlice

func ToIntSlice(i interface{}) ([]int, error)

ToIntSlice casts an empty interface to a []int.

func ToSlice

func ToSlice(i interface{}) ([]interface{}, error)

ToSlice casts an empty interface to a []interface{}.

func ToSliceStringMap

func ToSliceStringMap(i interface{}) ([]map[string]interface{}, error)

ToSliceStringMap casts an empty interface to a []interface{}.

func ToString

func ToString(i interface{}) (string, error)

ToString casts an empty interface to a string.

func ToStringMap

func ToStringMap(i interface{}) (map[string]interface{}, error)

ToStringMap casts an empty interface to a map[string]interface{}.

func ToStringMapBool

func ToStringMapBool(i interface{}) (map[string]bool, error)

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

func ToStringMapString

func ToStringMapString(i interface{}) (map[string]string, error)

ToStringMapString casts an empty interface to a stringmap

func ToStringMapStringSlice

func ToStringMapStringSlice(i interface{}) (map[string][]string, error)

ToStringMapStringSlice cast an empty interface to a string array map

func ToStringSlice

func ToStringSlice(i interface{}) ([]string, error)

ToStringSlice casts an empty interface to a []string.

func ToTime

func ToTime(i interface{}) (tim time.Time, err error)

ToTime casts an empty interface to time.Time.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL