lockbox

password manager
Log | Files | Refs | README | LICENSE

commit f020641ea3a1318c548c491bbd0f998cb7430fe5
parent 9e49bd9eb9a28e228775ff9316be3c735848cd0a
Author: Sean Enck <sean@ttypty.com>
Date:   Thu, 16 Feb 2023 19:22:22 -0500

adding this here

Diffstat:
Minternal/util/core.go | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/internal/util/core.go b/internal/util/core.go @@ -73,3 +73,11 @@ func ReadStdin(one bool) ([]byte, error) { } return b.Bytes(), nil } + +// IfNotSet will return the value or the default if the value is the value's default setting +func IfNotSet[T comparable](val, defaultTo T) T { + if val == *new(T) { + return defaultTo + } + return val +}