cast

package
v0.0.0-...-df7b6ad Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyValue    = errors.New("empty value")
	ErrNoCoveredType = errors.New("no covered type")
	ErrNoConvertible = errors.New("non-convertible type")
)

Functions

func ToKind

func ToKind(value reflect.Type) reflect.Kind

ToKind returns the kind of value

Types

type Cast

type Cast struct {
	// contains filtered or unexported fields
}

Cast is a cast

func ToType

func ToType(options ...OptionFunc) *Cast

ToType cast value to field type value

func (*Cast) Do

func (c *Cast) Do(field *structmap.FieldPart) error

Do has a ToType logic

type ConverterFunc

type ConverterFunc func(source reflect.Type, value reflect.Value) (result interface{}, err error)

ConverterFunc has logic on how to convert

type OptionFunc

type OptionFunc func(*Cast)

OptionFunc define options

func WithTypes

func WithTypes(types ...TypeFunc) OptionFunc

WithTypes packages everything in the cast

type TypeFunc

type TypeFunc func() (reflect.Type, ConverterFunc)

TypeFunc returns reflect.Type and ConverterFunc to this type

func Type

func Type(value interface{}, convert ConverterFunc) TypeFunc

Type creates a TypeFunc for this type

Jump to

Keyboard shortcuts

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