compare

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAndSetIfNotEmptyAndChanged

func NewAndSetIfNotEmptyAndChanged[T comparable](dst **T, src T) bool

NewAndSetIfNotEmptyAndChanged initializes a nil pointer destination and sets its value if different from source. Parameters:

  • dst: A double pointer to the destination value that may be nil
  • src: The source value to compare against and potentially set

Returns:

  • true if the destination was initialized or its value was changed
  • false if no change was needed (either dst was nil and src was zero value, or dst already equals src)

This function handles the case where the destination pointer is nil by creating a new instance. If the destination is nil, it creates a new instance and sets it to the source value.

func SetIfChanged

func SetIfChanged[T comparable](dst *T, src T) bool

SetIfChanged sets the destination pointer to the source value if they are different. Returns true if the value was changed, false otherwise.

func SetIfNotEmptyAndChanged

func SetIfNotEmptyAndChanged[T comparable](dst *T, src T) bool

SetIfNotEmptyAndChanged sets the destination pointer to the source value if they are different and src is not empty. Returns true if the value was changed, false otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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