convert

package
v0.0.0-...-401e8d7 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToInt

func ToInt(from any) (int, error)

ToInt converts from to an int.

If from is an integer or a float, a time.Duration, a time.Month or a time.Weekday a direct type convertion will be made.

If from is a bool, it will return 1 for true and 0 for false.

If from is time.Time, it will return the Unix time.

If from is a string, strconv will be used.

No other types are allowed and will result in an error.

func ToInt16

func ToInt16(from any) (int16, error)

ToInt16 converts from to an int16.

If from is an integer or a float, a time.Duration, a time.Month or a time.Weekday a direct type convertion will be made.

If from is a bool, it will return 1 for true and 0 for false.

If from is time.Time, it will return the Unix time.

If from is a string, strconv will be used.

No other types are allowed and will result in an error.

func ToInt32

func ToInt32(from any) (int32, error)

ToInt32 converts from to an int32.

If from is an integer or a float, a time.Duration, a time.Month or a time.Weekday a direct type convertion will be made.

If from is a bool, it will return 1 for true and 0 for false.

If from is time.Time, it will return the Unix time.

If from is a string, strconv will be used.

No other types are allowed and will result in an error.

func ToInt64

func ToInt64(from any) (int64, error)

ToInt64 converts from to an int64.

If from is an integer or a float, a time.Duration, a time.Month or a time.Weekday a direct type convertion will be made.

If from is a bool, it will return 1 for true and 0 for false.

If from is time.Time, it will return the Unix time.

If from is a string, strconv will be used.

No other types are allowed and will result in an error.

func ToInt8

func ToInt8(from any) (int8, error)

ToInt8 converts from to an int8.

If from is an integer or a float, a time.Duration, a time.Month or a time.Weekday a direct type convertion will be made.

If from is a bool, it will return 1 for true and 0 for false.

If from is time.Time, it will return the Unix time.

If from is a string, strconv will be used.

No other types are allowed and will result in an error.

func ToUint

func ToUint(from any) (uint, error)

ToUint converts from to an uint.

If from is an integer or a float, a time.Duration, a time.Month or a time.Weekday a direct type convertion will be made.

If from is a bool, it will return 1 for true and 0 for false.

If from is time.Time, it will return the Unix time.

If from is a string, strconv will be used.

No other types are allowed and will result in an error.

func ToUint16

func ToUint16(from any) (uint16, error)

ToUint16 converts from to an uint16.

If from is an integer or a float, a time.Duration, a time.Month or a time.Weekday a direct type convertion will be made.

If from is a bool, it will return 1 for true and 0 for false.

If from is time.Time, it will return the Unix time.

If from is a string, strconv will be used.

No other types are allowed and will result in an error.

func ToUint32

func ToUint32(from any) (uint32, error)

ToUint32 converts from to an uint32.

If from is an integer or a float, a time.Duration, a time.Month or a time.Weekday a direct type convertion will be made.

If from is a bool, it will return 1 for true and 0 for false.

If from is time.Time, it will return the Unix time.

If from is a string, strconv will be used.

No other types are allowed and will result in an error.

func ToUint64

func ToUint64(from any) (uint64, error)

ToUint64 converts from to an uint64.

If from is an integer or a float, a time.Duration, a time.Month or a time.Weekday a direct type convertion will be made.

If from is a bool, it will return 1 for true and 0 for false.

If from is time.Time, it will return the Unix time.

If from is a string, strconv will be used.

No other types are allowed and will result in an error.

func ToUint8

func ToUint8(from any) (uint8, error)

ToUint8 converts from to an uint8.

If from is an integer or a float, a time.Duration, a time.Month or a time.Weekday a direct type convertion will be made.

If from is a bool, it will return 1 for true and 0 for false.

If from is time.Time, it will return the Unix time.

If from is a string, strconv will be used.

No other types are allowed and will result in an error.

func ToUintptr

func ToUintptr(from any) (uintptr, error)

ToUintptr converts from to an uintptr.

If from is an integer or a float, a time.Duration, a time.Month or a time.Weekday a direct type convertion will be made.

If from is a bool, it will return 1 for true and 0 for false.

If from is time.Time, it will return the Unix time.

If from is a string, strconv will be used.

No other types are allowed and will result in an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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