basic

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package basic implements scalar conversions used by mconv.

Applications should normally import github.com/graingo/mconv and use its root-level functions. This package remains public for v1 compatibility.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToBool

func ToBool(value interface{}) bool

ToBool converts any type to bool.

func ToBoolE

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

ToBoolE converts any type to bool with error.

func ToComplex64

func ToComplex64(value interface{}) complex64

ToComplex64 converts any type to complex64.

func ToComplex64E

func ToComplex64E(value interface{}) (complex64, error)

ToComplex64E converts any type to complex64 with error.

func ToComplex128

func ToComplex128(value interface{}) complex128

ToComplex128 converts any type to complex128.

func ToComplex128E

func ToComplex128E(value interface{}) (complex128, error)

ToComplex128E converts any type to complex128 with error.

func ToDuration added in v0.1.2

func ToDuration(value interface{}) time.Duration

ToDuration converts any type to time.Duration.

func ToDurationE added in v0.1.2

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

ToDurationE converts any type to time.Duration with error.

func ToFloat32

func ToFloat32(value interface{}) float32

ToFloat32 converts any type to float32.

func ToFloat32E

func ToFloat32E(value interface{}) (float32, error)

ToFloat32E converts any type to float32 with error.

func ToFloat64

func ToFloat64(value interface{}) float64

ToFloat64 converts any type to float64.

func ToFloat64E

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

ToFloat64E converts any type to float64 with error.

func ToInt

func ToInt(value interface{}) int

ToInt converts value to int and returns zero when conversion fails.

func ToInt8

func ToInt8(value interface{}) int8

ToInt8 converts value to int8 and returns zero when conversion fails.

func ToInt8E

func ToInt8E(value interface{}) (int8, error)

ToInt8E converts value to int8.

func ToInt16

func ToInt16(value interface{}) int16

ToInt16 converts value to int16 and returns zero when conversion fails.

func ToInt16E

func ToInt16E(value interface{}) (int16, error)

ToInt16E converts value to int16.

func ToInt32

func ToInt32(value interface{}) int32

ToInt32 converts value to int32 and returns zero when conversion fails.

func ToInt32E

func ToInt32E(value interface{}) (int32, error)

ToInt32E converts value to int32.

func ToInt64

func ToInt64(value interface{}) int64

ToInt64 converts value to int64 and returns zero when conversion fails.

func ToInt64E

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

ToInt64E converts value to int64.

func ToIntE

func ToIntE(value interface{}) (int, error)

ToIntE converts value to int.

func ToString

func ToString(value interface{}) string

ToString converts any type to string

func ToStringE

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

ToStringE converts any type to string with error

func ToTime

func ToTime(value interface{}, formats ...string) time.Time

ToTime converts any type to time.Time. When value is a string, it will be parsed using the formats.

func ToTimeE

func ToTimeE(value interface{}, formats ...string) (time.Time, error)

ToTimeE converts any type to time.Time with error. When value is a string, it will be parsed using the formats.

func ToUint

func ToUint(value interface{}) uint

ToUint converts value to uint and returns zero when conversion fails.

func ToUint8

func ToUint8(value interface{}) uint8

ToUint8 converts value to uint8 and returns zero when conversion fails.

func ToUint8E

func ToUint8E(value interface{}) (uint8, error)

ToUint8E converts value to uint8.

func ToUint16

func ToUint16(value interface{}) uint16

ToUint16 converts value to uint16 and returns zero when conversion fails.

func ToUint16E

func ToUint16E(value interface{}) (uint16, error)

ToUint16E converts value to uint16.

func ToUint32

func ToUint32(value interface{}) uint32

ToUint32 converts value to uint32 and returns zero when conversion fails.

func ToUint32E

func ToUint32E(value interface{}) (uint32, error)

ToUint32E converts value to uint32.

func ToUint64

func ToUint64(value interface{}) uint64

ToUint64 converts value to uint64 and returns zero when conversion fails.

func ToUint64E

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

ToUint64E converts value to uint64.

func ToUintE

func ToUintE(value interface{}) (uint, error)

ToUintE converts value to uint.

Types

This section is empty.

Jump to

Keyboard shortcuts

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