package
0.0.0-20241221112132-06f9af878c14
Repository: https://github.com/brpaz/lib-go.git
Documentation: pkg.go.dev
# README
ptrutil
import "github.com/brpaz/lib-go/ptrutil"
Package ptrutil provides utility functions for working with pointers.
Index
- func Deref[T any](ptr *T, defaultValue T) T
- func Equal[T comparable](ptr1, ptr2 *T) bool
- func IsNil[T any](ptr *T) bool
- func Ptr[T any](value T) *T
func Deref
func Deref[T any](ptr *T, defaultValue T) T
Deref safely dereferences a pointer and returns the value. If the pointer is nil, it returns the specified default value.
func Equal
func Equal[T comparable](ptr1, ptr2 *T) bool
Equal checks if two pointers point to the same value or if both are nil.
func IsNil
func IsNil[T any](ptr *T) bool
IsNil checks whether a given pointer is nil.
func Ptr
func Ptr[T any](value T) *T
Ptr creates a pointer to the given value.
Generated by gomarkdoc