conv

package
v1.0.40 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(from interface{}) (bool, error)

Bool will convert the given value to a bool, returns the default value of false if a conversion can not be made.

func Duration

func Duration(from interface{}) (time.Duration, error)

Duration will convert the given value to a time.Duration, returns the default value of 0ns if a conversion can not be made.

func Float32

func Float32(from interface{}) (float32, error)

Float32 will convert the given value to a float32, returns the default value of 0.0 if a conversion can not be made.

func Float64

func Float64(from interface{}) (float64, error)

Float64 will convert the given value to a float64, returns the default value of 0.0 if a conversion can not be made.

func Infer

func Infer(into, from interface{}) error

Infer will perform conversion by inferring the conversion operation from the base type of a pointer to a supported T.

Example:

var into int64
err := conv.Infer(&into, `12`)
// into -> 12

See examples for more usages.

func Int

func Int(from interface{}) (int, error)

Int will convert the given value to a int, returns the default value of 0 if a conversion can not be made.

func Int16

func Int16(from interface{}) (int16, error)

Int16 will convert the given value to a int16, returns the default value of 0 if a conversion can not be made.

func Int32

func Int32(from interface{}) (int32, error)

Int32 will convert the given value to a int32, returns the default value of 0 if a conversion can not be made.

func Int64

func Int64(from interface{}) (int64, error)

Int64 will convert the given value to a int64, returns the default value of 0 if a conversion can not be made.

func Int8

func Int8(from interface{}) (int8, error)

Int8 will convert the given value to a int8, returns the default value of 0 if a conversion can not be made.

func String

func String(from interface{}) (string, error)

String will convert the given value to a string, returns the default value of "" if a conversion can not be made.

func Time

func Time(from interface{}) (time.Time, error)

Time will convert the given value to a time.Time, returns the empty struct time.Time{} if a conversion can not be made.

func Uint

func Uint(from interface{}) (uint, error)

Uint will convert the given value to a uint, returns the default value of 0 if a conversion can not be made.

func Uint16

func Uint16(from interface{}) (uint16, error)

Uint16 will convert the given value to a uint16, returns the default value of 0 if a conversion can not be made.

func Uint32

func Uint32(from interface{}) (uint32, error)

Uint32 will convert the given value to a uint32, returns the default value of 0 if a conversion can not be made.

func Uint64

func Uint64(from interface{}) (uint64, error)

Uint64 will convert the given value to a uint64, returns the default value of 0 if a conversion can not be made.

func Uint8

func Uint8(from interface{}) (uint8, error)

Uint8 will convert the given value to a uint8, returns the default value of 0 if a conversion can not be made.

Types

This section is empty.

Directories

Path Synopsis
internal
convert
Package convert contains common conversion interfaces.
Package convert contains common conversion interfaces.
refconv
Package refconv implements the Converter interface by using the standard libraries reflection package.
Package refconv implements the Converter interface by using the standard libraries reflection package.

Jump to

Keyboard shortcuts

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