1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-12-26 00:01:35 +02:00
Files
oauth2-proxy/pkg/util/ptr/ptr.go
Jan Larwig 0eec65e230 refactor: ptr.Ptr to ptr.To
Signed-off-by: Jan Larwig <jan@larwig.com>
2025-11-16 22:38:59 +01:00

15 lines
250 B
Go

package ptr
// To generically returns a pointer to the given value.
func To[T any](v T) *T {
return &v
}
// Deref returns the value of the pointer or def(ault) if nil.
func Deref[T any](p *T, def T) T {
if p == nil {
return def
}
return *p
}