reflectjuice

package
v1.36.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2025 License: MIT Imports: 2 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL