cast

package
v1.4.13 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: MIT Imports: 4 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToBool

func ToBool(i interface{}) bool

ToBool casts a interfacfe to bool. It accepts

true: 1, t, T, TRUE, true, True
false: 0, f, F, FALSE, false, False, any other value.

func ToDuration

func ToDuration(i interface{}) time.Duration

ToDuration casts a interfacfe to time.Duration.

func ToFloat64

func ToFloat64(i interface{}) float64

ToFloat64 casts a interfacfe to float64.

func ToInt

func ToInt(i interface{}) int

ToInt casts a interfacfe to int.

func ToInt64

func ToInt64(i interface{}) int64

ToInt64 casts a interfacfe to int64.

func ToMap added in v1.2.1

func ToMap(in interface{}, tagName ...string) (map[string]interface{}, error)

ToMap casts a struct to map. reference: https://www.sobyte.net/post/2021-06/several-ways-to-convert-struct-to-mapstringinterface/

func ToString

func ToString(i interface{}) string

ToString casts a interface to string.

func ToTime

func ToTime(i interface{}) time.Time

ToTime casts a interfacfe to time.Time.

func ToUint

func ToUint(i interface{}) uint

ToUint casts a interfacfe to uint.

func ToUint64

func ToUint64(i interface{}) uint64

ToUint64 casts a interfacfe to uint64.

Types

This section is empty.

Jump to

Keyboard shortcuts

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