gonull
gonull copied to clipboard
Add a comparison method that will compare Nullibles by value.
For example
func NullIsEqual[T comparable](a gonull.Nullable[T], b gonull.Nullable[T]) bool {
// If both are not present, they are considered equal
if !a.Present && !b.Present {
return true
}
// If both are present and values are equal, they are considered equal
return a.Present && b.Present && a.Val == b.Val
}
func NewNull[T comparable](value T) gonull.Nullable[T] {
return gonull.Nullable[T](gonull.NewNullable(value))
}