mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-06 06:02:18 +02:00
1 parent
83ba882bab
commit
43de021ac1
2 files changed
+38
-49
No files matched your search
@@ -212,3 +212,12 @@ func ToFloat64(number any) (float64, error) {
|
||||
func ToPointer[T any](val T) *T {
|
||||
return &val
|
||||
}
|
||||
|
||||
// IfZero returns "def" if "v" is a zero value, otherwise "v"
|
||||
func IfZero[T comparable](v, def T) T {
|
||||
var zero T
|
||||
if v == zero {
|
||||
return def
|
||||
}
|
||||
return v
|
||||
}
|
||||
Reference in new issue
Block a user