Documentation ¶
Overview ¶
Description: This package contains helper functions for working with the reflect package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReplaceNilPointersFields ¶
func ReplaceNilPointersFields(toUpdate, currentDocument interface{}) error
ReplaceNilPointersFields replaces nil pointer fields in the first struct (toUpdate) with the corresponding values from the second struct (currentDocument).
Key Principles: - Only nil pointers in `toUpdate` will be replaced by the corresponding values from `currentDocument`. - Deep copying prevents the structs from sharing underlying data references. - Non-nil fields remain untouched in `toUpdate`. - Unexported fields will be skipped. - Supports nested struct pointers with recursive handling. - Prevents panic for non-struct primitive types.
Supported Input Combinations: - `toUpdate` and `currentDocument` can be:
- An interface holding a struct directly.
- An interface holding a pointer to a struct.
- A pointer to a struct directly.
- A struct directly.
Types ¶
This section is empty.