Published fragment ValOrDefault, on a pair of helper functions ValOrDefault
and ValOrDefaultFunc
that can help significantly to clean up Go code around assigning default values.
And actually, an update: Go 1.22’s cmp.Or
supersedes this custom helper.