types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeBool = reflect.TypeOf(false)

TypeBool represents the bool type.

View Source
var TypeFloat32 = reflect.TypeOf(float32(0))

TypeFloat32 represents the float32 type.

View Source
var TypeFloat64 = reflect.TypeOf(float64(0))

TypeFloat64 represents the float64 type.

View Source
var TypeInt = reflect.TypeOf(0)

TypeInt represents the int type.

View Source
var TypeInt16 = reflect.TypeOf(int16(0))

TypeInt16 represents the int16 type.

View Source
var TypeInt32 = reflect.TypeOf(int32(0))

TypeInt32 represents the int32 type.

View Source
var TypeInt64 = reflect.TypeOf(int64(0))

TypeInt64 represents the int64 type.

View Source
var TypeInt8 = reflect.TypeOf(int8(0))

TypeInt8 represents the int8 type.

View Source
var TypeString = reflect.TypeOf("")

TypeString represents the string type.

View Source
var TypeUint = reflect.TypeOf(uint(0))

TypeUint represents the uint type.

View Source
var TypeUint16 = reflect.TypeOf(uint16(0))

TypeUint16 represents the uint16 type.

View Source
var TypeUint32 = reflect.TypeOf(uint32(0))

TypeUint32 represents the uint32 type.

View Source
var TypeUint64 = reflect.TypeOf(uint64(0))

TypeUint64 represents the uint64 type.

View Source
var TypeUint8 = reflect.TypeOf(uint8(0))

TypeUint8 represents the uint8 type.

Functions

func TypeExtractor

func TypeExtractor(v any) (reflect.Type, error)

TypeExtractor is a function for use with conversions.WithTypeExtractor that returns the reflect.Type of the value passed in.

Types

type Conversions

type Conversions = conversions.Conversions[reflect.Type, any]

Conversion is a type alias for a Conversions instance that is used for converting between Go types.

func New

func New(opts ...Option) (*Conversions, error)

New creates a new Conversions instance configured to convert between Go types.

type Converter

type Converter = conversions.Converter[any]

type Option

type Option = conversions.Option[reflect.Type, any]

func WithDefaultConversions

func WithDefaultConversions() Option

WithDefaultConversions makes default type conversions available, this will add converters between the built-in types, such as string to int. The following types are supported: string, int, int8, in16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64, bool.

These converters run in safe mode where they will error if they can not convert the value, such as turning a non-numeric string into an int. Or uint64 into an int32 if the value is too large.

Jump to

Keyboard shortcuts

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