1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-03-22 22:35:06 +00:00
Files
pocket-id/backend/internal/utils/ptr_util.go
Kyle Mendell a90c8abe51 chore(deps): upgrade to node 24 and go 1.26.0 (#1328)
Co-authored-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Co-authored-by: Elias Schneider <login@eliasschneider.com>
2026-02-23 19:50:44 +01:00

12 lines
214 B
Go

package utils
// PtrOrNil returns a pointer to v if v is not the zero value of its type,
// otherwise it returns nil.
func PtrOrNil[T comparable](v T) *T {
var zero T
if v == zero {
return nil
}
return &v
}