Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
FieldName string
OldValue interface{}
NewValue interface{}
}
Result represents the comparison outcome of a field, including its name, old value, and new value.
func CompareStructs ¶
CompareStructs compares two struct instances (or pointers to structs) and returns their differences.
Only fields explicitly tagged with `updatable` are compared. Supported tag formats:
- `updatable:"true"` → uses the struct field name
- `updatable:"custom_name"` → uses the custom field name in results
This function supports:
- Structs and pointers to structs (including nil pointers)
- Recursively comparing nested structs (excluding time.Time)
- Comparing primitives, slices, arrays, maps, and pointers
If a field's value differs (based on reflect.DeepEqual), the field is added to the result.
The optional `prefix` is used for naming nested fields like `data.age`.
Click to show internal directories.
Click to hide internal directories.