Documentation
¶
Index ¶
- Variables
- func AddStringToCache(value interface{}, result string)
- func AddTimeToCache(value interface{}, result time.Time)
- func CacheConversion(source, target reflect.Type, convertible bool)
- func ClearAllCaches()
- func ClearAllReflectCaches()
- func ClearConversionCache()
- func ClearStringCache()
- func ClearTimeCache()
- func ClearTypeInfoCache()
- func GetCachedConversion(source, target reflect.Type) (bool, bool)
- func GetStringFromCache(value interface{}) (string, bool)
- func GetTimeFromCache(value interface{}) (time.Time, bool)
- func SetConversionCacheSize(size int)
- func SetStringCacheSize(size int)
- func SetTimeCacheSize(size int)
- func SetTypeInfoCacheSize(size int)
- type ConversionError
- type ConversionPair
- type TypeInfo
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilValue = errors.New("input value is nil") ErrUnsupportedType = errors.New("unsupported type") ErrConversionFailed = errors.New("conversion failed") ErrOverflow = errors.New("value overflow") ErrInvalidFormat = errors.New("invalid format") ErrInvalidTimeFormat = errors.New("invalid time format") ErrInvalidJSONFormat = errors.New("invalid JSON format") )
define errors
Functions ¶
func AddStringToCache ¶
func AddStringToCache(value interface{}, result string)
AddStringToCache adds string to cache.
func AddTimeToCache ¶
AddTimeToCache adds time to cache.
func CacheConversion ¶
CacheConversion caches a type conversion result
func ClearAllReflectCaches ¶
func ClearAllReflectCaches()
ClearAllReflectCaches clears all reflection-related caches
func ClearConversionCache ¶
func ClearConversionCache()
ClearConversionCache clears the type conversion cache
func ClearTypeInfoCache ¶
func ClearTypeInfoCache()
ClearTypeInfoCache clears the type information cache
func GetCachedConversion ¶
GetCachedConversion gets a cached type conversion result
func GetStringFromCache ¶
GetStringFromCache gets string from cache.
func GetTimeFromCache ¶
GetTimeFromCache gets time from cache.
func SetConversionCacheSize ¶
func SetConversionCacheSize(size int)
SetConversionCacheSize sets the type conversion cache size
func SetTypeInfoCacheSize ¶
func SetTypeInfoCacheSize(size int)
SetTypeInfoCacheSize sets the type information cache size
Types ¶
type ConversionError ¶
ConversionError represents a conversion error.
func NewConversionError ¶
func NewConversionError(value interface{}, targetType string, err error) *ConversionError
NewConversionError creates a new conversion error.
func (*ConversionError) Error ¶
func (e *ConversionError) Error() string
Error implements the error interface.
func (*ConversionError) Unwrap ¶
func (e *ConversionError) Unwrap() error
Unwrap returns the underlying error.
type ConversionPair ¶
ConversionPair represents a source-target type pair for conversion caching
type TypeInfo ¶
type TypeInfo struct {
// Basic type information
Type reflect.Type
Kind reflect.Kind
IsBasic bool
IsContainer bool
// Struct field information
Fields map[string]reflect.StructField
FieldNames []string
// Method information
Methods map[string]reflect.Method
// Type conversion information
ConvertibleTo map[reflect.Type]bool
AssignableTo map[reflect.Type]bool
}
TypeInfo stores reflection information about a type
func GetTypeInfo ¶
GetTypeInfo gets reflection information about a type, preferably from cache
func (*TypeInfo) IsAssignableTo ¶
IsAssignableTo checks if the type can be assigned to the target type, result is cached