mirror of
https://github.com/sbondCo/Watcharr.git
synced 2026-08-07 15:25:29 +00:00
12 lines
231 B
Go
12 lines
231 B
Go
package util
|
|
|
|
// Safe dereferencing of pointers to make
|
|
// our core logic more readable.
|
|
// If the ptr is nil, def (a default value) is returned.
|
|
func Deref[T any](ptr *T, def T) T {
|
|
if ptr == nil {
|
|
return def
|
|
}
|
|
return *ptr
|
|
}
|