/
mws-cloud-platform
/
util-toolset
Обзор
Документация
Войти
/
mws-cloud-platform
/
util-toolset
Код
Пакеты
0
Релизы
0
CI/CD
Аналитика
master
pkg/utils/ptr/ptr.go
35 строк
630 B
romanov-is-here
code sync
09 дек 2025, 15:43
Верифицирован
09 дек 2025, 15:43
baddc44
Код
Авторство
О чём код?
// Package ptr provides helper functions for working with pointers. package ptr // Get returns a pointer for the passed value. func Get[T any](v T) *T { return &v } // Value returns the value in the pointer or the zero value if the pointer is nil. func Value[T any](p *T) T { if p == nil { var zero T return zero } return *p } // Clone returns a new pointer object. func Clone[T any](p *T) *T { if p == nil { return nil } clone := *p return &clone } // Equal compares the values in the pointers. func Equal[T comparable](p1, p2 *T) bool { if p1 == nil || p2 == nil { return p1 == p2 } return *p1 == *p2 }