cast

package
v1.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

README

cast

提供了很多类型之间相互转换的函数。

方法列表

方法名 功能
ToBool casts an interface{} to a bool.
ToBoolE casts an interface{} to a bool.
ToInt casts an interface{} to an int.
ToInt64 casts an interface{} to an int64.
ToInt64E casts an interface{} to an int64.
ToUint64 casts an interface{} to a uint64.
ToUint64E casts an interface{} to a uint64.
ToFloat64 casts an interface{} to a float64.
ToFloat64E casts an interface{} to a float64.
ToString casts an interface{} to a string.
ToStringE casts an interface{} to a string.
ToDuration casts an interface{} to a time.Duration.
ToDurationE casts an interface{} to a time.Duration.
ToTime casts an interface{} to a time.Time.
ToTimeE casts an interface{} to a time.Time.
ToStringSlice casts an interface to a []string type.
ToStringSliceE casts an interface to a []string type.

Documentation

Overview

Package cast 提供了很多类型之间相互转换的函数。 Thanks the github.com/spf13/cast project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToBool

func ToBool(i interface{}) bool

ToBool casts an interface{} to a bool.

func ToBoolE

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

ToBoolE casts an interface{} to a bool.

func ToDuration

func ToDuration(i interface{}) time.Duration

ToDuration casts an interface{} to a time.Duration.

func ToDurationE

func ToDurationE(i interface{}) (time.Duration, error)

ToDurationE casts an interface{} to a time.Duration.

func ToFloat64

func ToFloat64(i interface{}) float64

ToFloat64 casts an interface{} to a float64.

func ToFloat64E

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

ToFloat64E casts an interface{} to a float64.

func ToInt

func ToInt(i interface{}) int

ToInt casts an interface{} to an int.

func ToInt64

func ToInt64(i interface{}) int64

ToInt64 casts an interface{} to an int64.

func ToInt64E

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

ToInt64E casts an interface{} to an int64.

func ToString

func ToString(i interface{}) string

ToString casts an interface{} to a string.

func ToStringE

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

ToStringE casts an interface{} to a string.

func ToStringSlice

func ToStringSlice(i interface{}) []string

ToStringSlice casts an interface to a []string type.

func ToStringSliceE

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

ToStringSliceE casts an interface to a []string type.

func ToTime

func ToTime(i interface{}) time.Time

ToTime casts an interface{} to a time.Time.

func ToTimeE

func ToTimeE(i interface{}) (time.Time, error)

ToTimeE casts an interface{} to a time.Time.

func ToUint64

func ToUint64(i interface{}) uint64

ToUint64 casts an interface{} to a uint64.

func ToUint64E

func ToUint64E(i interface{}) (uint64, error)

ToUint64E casts an interface{} to a uint64.

Types

This section is empty.

Jump to

Keyboard shortcuts

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