Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Merge ¶
func Merge(dst, src any)
Merge copies non-zero fields from src into dst recursively.
dst and src must have the same concrete type (or identical field layout for structs). Mismatched types will cause a panic.
For each field in src:
- Pointers: copied if non-nil (the pointed-to value is NOT inspected)
- Interfaces: copied if non-nil
- Strings: copied if non-empty
- Numbers: copied if non-zero
- Bools: ALWAYS copied (use *bool for optional bools)
- Slices/maps: replaced if non-empty (element-level merging is NOT performed)
- Structs: merged field-by-field recursively
- Channels/funcs/arrays/unsafe pointers: intentionally skipped
Unexported struct fields are skipped.
dst must be a non-nil pointer to a struct. src must be a struct or pointer to struct. Either constraint violation causes Merge to panic.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.