quintodrome/utils/gg/gg.go
Deluan efe9291db0 refactor: multiple syntax updates for Go 1.26
Signed-off-by: Deluan <deluan@navidrome.org>
2026-05-19 18:02:36 -03:00

18 lines
362 B
Go

// Package gg implements simple "extensions" to Go language. Based on https://github.com/icza/gog
package gg
// V returns the value of the input pointer, or a zero value if the input pointer is nil.
func V[T any](p *T) T {
if p == nil {
var zero T
return zero
}
return *p
}
func If[T any](cond bool, v1, v2 T) T {
if cond {
return v1
}
return v2
}