v0.0.409
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m41s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m41s
This commit is contained in:
@@ -5,12 +5,76 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func Coalesce[T any](v *T, def T) T {
|
||||
if v == nil {
|
||||
return def
|
||||
} else {
|
||||
return *v
|
||||
func Coalesce[T any](v1 *T, def T) T {
|
||||
if v1 != nil {
|
||||
return *v1
|
||||
}
|
||||
|
||||
return def
|
||||
}
|
||||
|
||||
func CoalesceOpt[T any](v1 *T, v2 *T) *T {
|
||||
if v1 != nil {
|
||||
return v1
|
||||
}
|
||||
|
||||
return v2
|
||||
}
|
||||
|
||||
func Coalesce3[T any](v1 *T, v2 *T, def T) T {
|
||||
if v1 != nil {
|
||||
return *v1
|
||||
}
|
||||
|
||||
if v2 != nil {
|
||||
return *v2
|
||||
}
|
||||
|
||||
return def
|
||||
}
|
||||
|
||||
func Coalesce3Opt[T any](v1 *T, v2 *T, v3 *T) *T {
|
||||
if v1 != nil {
|
||||
return v1
|
||||
}
|
||||
|
||||
if v2 != nil {
|
||||
return v2
|
||||
}
|
||||
|
||||
return v3
|
||||
}
|
||||
|
||||
func Coalesce4[T any](v1 *T, v2 *T, v3 *T, def T) T {
|
||||
if v1 != nil {
|
||||
return *v1
|
||||
}
|
||||
|
||||
if v2 != nil {
|
||||
return *v2
|
||||
}
|
||||
|
||||
if v3 != nil {
|
||||
return *v3
|
||||
}
|
||||
|
||||
return def
|
||||
}
|
||||
|
||||
func Coalesce4Opt[T any](v1 *T, v2 *T, v3 *T, v4 *T) *T {
|
||||
if v1 != nil {
|
||||
return v1
|
||||
}
|
||||
|
||||
if v2 != nil {
|
||||
return v2
|
||||
}
|
||||
|
||||
if v3 != nil {
|
||||
return v3
|
||||
}
|
||||
|
||||
return v4
|
||||
}
|
||||
|
||||
func CoalesceString(s *string, def string) string {
|
||||
|
Reference in New Issue
Block a user