Documentation ¶
Index ¶
- Variables
- func Bool(v any) bool
- func Cast[R any, T any](v T, tags ...string) R
- func CastContext[R any, T any](ctx context.Context, v T, tags ...string) R
- func CastRecursive[R any, T any](v T, tags ...string) R
- func CastRecursiveContext[R any, T any](ctx context.Context, v T, tags ...string) R
- func Float(v any) float64
- func Float32(v any) float32
- func Float64(v any) float64
- func Int(v any) int
- func Int16(v any) int16
- func Int32(v any) int32
- func Int64(v any) int64
- func Int8(v any) int8
- func IsEmpty[T any](v T) bool
- func IsEmptyByReflection(v reflect.Value) bool
- func Len[T any](val T) int
- func Map[K comparable, V any](src any, tags ...string) map[K]V
- func MapContext[K comparable, V any](ctx context.Context, src any, tags ...string) map[K]V
- func MapRecursive[K comparable, V any](src any, tags ...string) map[K]V
- func MapRecursiveContext[K comparable, V any](ctx context.Context, src any, tags ...string) map[K]V
- func Number[R Numeric](v any) R
- func ParseTime(tm string) (t time.Time, err error)
- func ReflectStr(v reflect.Value) string
- func ReflectStructFieldValue(st reflect.Value, names ...string) (any, error)
- func ReflectToBool(v reflect.Value) bool
- func ReflectToFloat64(v reflect.Value) float64
- func ReflectToInt64(v reflect.Value) int64
- func ReflectToString(v reflect.Value) stringdeprecated
- func ReflectToType(v reflect.Value, t reflect.Type, tags ...string) any
- func ReflectToTypeContext(ctx context.Context, v reflect.Value, t reflect.Type, tags ...string) any
- func ReflectTryToType(v reflect.Value, t reflect.Type, recursive bool, tags ...string) (any, error)
- func ReflectTryToTypeContext(ctx context.Context, v reflect.Value, t reflect.Type, recursive bool, ...) (any, error)
- func SetStructFieldValue(ctx context.Context, st any, name string, value any) (err error)
- func Slice[R any, S any](src []S, tags ...string) []R
- func SliceContext[R any, S any](ctx context.Context, src []S, tags ...string) []R
- func Str(v any) string
- func Struct[R any](src any, tags ...string) (R, error)
- func StructContext[R any](ctx context.Context, src any, tags ...string) (R, error)
- func StructFieldTags(st any, tag string) map[string]string
- func StructFieldTagsUnsorted(st any, tag string) ([]string, []string)
- func StructFieldValue(st any, names ...string) (any, error)
- func StructFields(st any, tag string) []string
- func To(v, to any, tags ...string) any
- func ToBool(v any) booldeprecated
- func ToFloat(v any) float64deprecated
- func ToFloat32(v any) float32deprecated
- func ToFloat64(v any) float64deprecated
- func ToFloat64Slice(v any) []float64deprecated
- func ToInt(v any) intdeprecated
- func ToInt16(v any) int16deprecated
- func ToInt32(v any) int32deprecated
- func ToInt64(v any) int64deprecated
- func ToIntSlice(v any) []intdeprecated
- func ToInterfaceSlice(v any) []anydeprecated
- func ToMap(dst, src any, recursive bool, tags ...string) error
- func ToMapContext(ctx context.Context, dst, src any, recursive bool, tags ...string) error
- func ToMapFrom(src any, recursive bool, tags ...string) (map[any]any, error)
- func ToSiMap(src any, recursive bool, tags ...string) (map[string]any, error)deprecated
- func ToSlice(dst, src any, tags ...string) errordeprecated
- func ToString(v any) stringdeprecated
- func ToStringMap(src any, recursive bool, tags ...string) (map[string]string, error)deprecated
- func ToStringSlice(v any) []stringdeprecated
- func ToStruct(dst, src any, tags ...string) errordeprecated
- func ToType(v any, t reflect.Type, tags ...string) any
- func ToUint(v any) uintdeprecated
- func ToUint16(v any) uint16deprecated
- func ToUint32(v any) uint32deprecated
- func ToUint64(v any) uint64deprecated
- func ToUint64ByReflect(v reflect.Value) uint64
- func TryAnySliceContext(ctx context.Context, dst, src any, tags ...string) error
- func TryCast[R any, T any](v T, tags ...string) (R, error)
- func TryCastContext[R any, T any](ctx context.Context, v T, tags ...string) (R, error)
- func TryCastRecursive[R any, T any](v T, tags ...string) (R, error)
- func TryCastRecursiveContext[R any, T any](ctx context.Context, v T, tags ...string) (R, error)
- func TryCastValue[R any, T any](v T, recursive bool, tags ...string) (R, error)
- func TryCastValueContext[R any, T any](ctx context.Context, v T, recursive bool, tags ...string) (R, error)
- func TryCopyStruct(dst, src any, tags ...string) (err error)
- func TryCopyStructContext(ctx context.Context, dst, src any, tags ...string) (err error)
- func TryMap[K comparable, V any](src any, tags ...string) (map[K]V, error)
- func TryMapContext[K comparable, V any](ctx context.Context, src any, tags ...string) (map[K]V, error)
- func TryMapCopy[K comparable, V any](dst map[K]V, src any, recursive bool, tags ...string) error
- func TryMapCopyContext[K comparable, V any](ctx context.Context, dst map[K]V, src any, recursive bool, tags ...string) error
- func TryMapFrom[K comparable, V any](src any, recursive bool, tags ...string) (map[K]V, error)
- func TryMapFromContext[K comparable, V any](ctx context.Context, src any, recursive bool, tags ...string) (map[K]V, error)
- func TryMapRecursive[K comparable, V any](src any, tags ...string) (map[K]V, error)
- func TryMapRecursiveContext[K comparable, V any](ctx context.Context, src any, tags ...string) (map[K]V, error)
- func TryNumber[R Numeric](v any) (R, error)
- func TryReflectStr(v reflect.Value) (string, error)
- func TryReflectToString(v reflect.Value) (string, error)deprecated
- func TrySlice[R any, S any](src []S, tags ...string) (res []R, err error)
- func TrySliceContext[R any, S any](ctx context.Context, src []S, tags ...string) (res []R, err error)
- func TryStr(v any) (string, error)
- func TryTo(v, to any, tags ...string) (any, error)
- func TryToContext(ctx context.Context, v, to any, tags ...string) (any, error)
- func TryToString(v any) (string, error)deprecated
- func TryToType(v any, t reflect.Type, tags ...string) (any, error)
- func TryToTypeContext(ctx context.Context, v any, t reflect.Type, tags ...string) (any, error)
- func Uint(v any) uint
- func Uint16(v any) uint16
- func Uint32(v any) uint32
- func Uint64(v any) uint64
- func Uint8(v any) uint8
- type CastSetter
- type Numeric
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidParams = errors.New("invalid params") ErrUnsupportedType = errors.New("unsupported destination type") ErrUnsupportedSourceType = errors.New("unsupported source type") ErrUnsettableValue = errors.New("can't set value") ErrUnsupportedNumericType = errors.New("unsupported numeric type") ErrStructFieldNameUndefined = errors.New("struct field name undefined") ErrStructFieldValueCantBeChanged = errors.New("struct field value cant be changed") )
Error list...
Functions ¶
func CastContext ¶
CastContext source type into the target type
func CastRecursive ¶
CastRecursive source type into the target type
func CastRecursiveContext ¶
CastRecursiveContext source type into the target type
func Map ¶
func Map[K comparable, V any](src any, tags ...string) map[K]V
Map creates map from source or returns nil
func MapContext ¶
MapContext creates map from source or returns nil
func MapRecursive ¶
func MapRecursive[K comparable, V any](src any, tags ...string) map[K]V
MapRecursive creates map from source or returns nil
func MapRecursiveContext ¶
MapRecursiveContext creates map from source or returns nil
func ReflectStr ¶
ReflectStr converts reflection value to string
func ReflectStructFieldValue ¶
ReflectStructFieldValue returns the value of the struct field
func ReflectToBool ¶
ReflectToBool returns boolean from reflection
func ReflectToFloat64 ¶
ReflectToFloat64 returns float64 from reflection
func ReflectToInt64 ¶
ReflectToInt64 returns int64 from reflection
func ReflectToString
deprecated
func ReflectToType ¶
ReflectToType converts reflection valut to reflection type or returns nil
func ReflectToTypeContext ¶
ReflectToType converts reflection valut to reflection type or returns nil
func ReflectTryToType ¶
ReflectTryToType converts reflection value to reflection type or returns error
func ReflectTryToTypeContext ¶
func ReflectTryToTypeContext(ctx context.Context, v reflect.Value, t reflect.Type, recursive bool, tags ...string) (any, error)
ReflectTryToTypeContext converts reflection value to reflection type or returns error
func SetStructFieldValue ¶
SetStructFieldValue puts value into the struct field
func SliceContext ¶
SliceContext converts one type of array to other or resturns nil if not compatible
func StructContext ¶
StructContext convert any input type into the target structure
func StructFieldTags ¶
StructFieldTags returns Map with key->tag matching
func StructFieldTagsUnsorted ¶
StructFieldTagsUnsorted returns field names and tag targets separately
func StructFieldValue ¶
StructFieldValue returns the value of the struct field
func StructFields ¶
StructFields returns the field names from the structure
func ToFloat64Slice
deprecated
func ToIntSlice
deprecated
func ToInterfaceSlice
deprecated
func ToMap ¶
ToMap cast your Source into the Destination type tag defines the tags name in the structure to map the keys
func ToMapContext ¶
ToMap cast your Source into the Destination type tag defines the tags name in the structure to map the keys
func ToStringSlice
deprecated
func ToUint64ByReflect ¶
ToUint64ByReflect returns uint64 from reflection
func TryAnySliceContext ¶
TryAnySliceContext converts any input slice into destination type slice
func TryCastContext ¶
TryCastContext source type into the target type
func TryCastRecursive ¶
TryCastRecursive source type into the target type with recursive data converting
func TryCastRecursiveContext ¶
TryCastRecursiveContext source type into the target type with recursive data converting
func TryCastValue ¶
TryCastValue source type into the target type
func TryCastValueContext ¶
func TryCastValueContext[R any, T any](ctx context.Context, v T, recursive bool, tags ...string) (R, error)
TryCastValueContext source type into the target type
func TryCopyStruct ¶
TryCopyStruct convert any input type into the target structure
func TryCopyStructContext ¶
TryCopyStructContext convert any input type into the target structure
func TryMap ¶
func TryMap[K comparable, V any](src any, tags ...string) (map[K]V, error)
TryMap creates new map to convert from soruce type
func TryMapContext ¶
func TryMapContext[K comparable, V any](ctx context.Context, src any, tags ...string) (map[K]V, error)
TryMapContext creates new map to convert from soruce type
func TryMapCopy ¶
TryMapCopy converts source into destination or return error
func TryMapCopyContext ¶
func TryMapCopyContext[K comparable, V any](ctx context.Context, dst map[K]V, src any, recursive bool, tags ...string) error
TryMapCopyContext converts source into destination or return error
func TryMapFrom ¶
TryMapFrom source creates new map to convert
func TryMapFromContext ¶
func TryMapFromContext[K comparable, V any](ctx context.Context, src any, recursive bool, tags ...string) (map[K]V, error)
TryMapFrom source creates new map to convert
func TryMapRecursive ¶
func TryMapRecursive[K comparable, V any](src any, tags ...string) (map[K]V, error)
TryMapRecursive creates new map to convert from soruce type with recursive field processing
func TryMapRecursiveContext ¶
func TryMapRecursiveContext[K comparable, V any](ctx context.Context, src any, tags ...string) (map[K]V, error)
TryMapRecursiveContext creates new map to convert from soruce type with recursive field processing
func TryReflectStr ¶
TryReflectStr converts reflection value to string
func TryReflectToString
deprecated
func TrySliceContext ¶
func TrySliceContext[R any, S any](ctx context.Context, src []S, tags ...string) (res []R, err error)
TrySliceContext converts one type of array to other or resturns error
func TryToContext ¶
TryToContext cast any input type into the target
func TryToString
deprecated
func TryToTypeContext ¶
TryToTypeContext cast any input type into the target reflection
Types ¶
type CastSetter ¶
CastSetter interface from some type into the specific value