Documentation
¶
Index ¶
- func FindChangedFieldsSimple[T any](original, updated *T, info *schema.ModelInfo) (map[string]interface{}, error)
- func IsZero(v reflect.Value) bool
- func NewPtr[T any]() T
- func NormalizeValue(value interface{}) interface{}
- func RegisterTypeRecursive(t reflect.Type)
- func ToPtr[T any](v T) *T
- func ToSnakeCase(str string) string
- type OrderedMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindChangedFieldsSimple ¶
func FindChangedFieldsSimple[T any](original, updated *T, info *schema.ModelInfo) (map[string]interface{}, error)
FindChangedFieldsSimple compares two structs (original and updated) using cached metadata for optimized comparison. It requires access to internal/schema types, so it lives in utils for now but could potentially be moved if dependencies change.
func IsZero ¶
IsZero checks if a reflect.Value is the zero value for its type. This handles various kinds including structs, slices, maps, pointers, and primitives.
func NewPtr ¶
func NewPtr[T any]() T
NewPtr returns a non-nil, zero-initialized value of type T (where T is a pointer type).
func NormalizeValue ¶
func NormalizeValue(value interface{}) interface{}
NormalizeValue recursively normalizes a value for consistent JSON marshaling. This is necessary to ensure a consistent cache key regardless of how the value was constructed.
func RegisterTypeRecursive ¶ added in v0.1.12
RegisterTypeRecursive registers the given type and all its fields recursively with gob.Register. It avoids duplicate registration by using the fully qualified type name as key. It also recovers from gob.Register panic to prevent test crash. Enhanced to register named type aliases found in struct fields.
func ToPtr ¶
func ToPtr[T any](v T) *T
ToPtr returns a pointer to the given value (if not already a pointer)
func ToSnakeCase ¶ added in v0.1.2
ToSnakeCase converts a string from CamelCase or PascalCase to snake_case.
Types ¶
type OrderedMap ¶
type OrderedMap struct {
// contains filtered or unexported fields
}
OrderedMap is a map that preserves key insertion order and supports JSON serialization.
func (*OrderedMap) Get ¶
func (om *OrderedMap) Get(key string) (interface{}, bool)
Get retrieves the value for a key.
func (*OrderedMap) Keys ¶
func (om *OrderedMap) Keys() []string
Keys returns the keys in insertion order.
func (*OrderedMap) MarshalJSON ¶
func (om *OrderedMap) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler, outputting keys in order.
func (*OrderedMap) Set ¶
func (om *OrderedMap) Set(key string, value interface{})
Set sets the value for a key, preserving insertion order.