github.com/songzhibin97/go-baseutils@v0.0.2-0.20240302024150-487d8ce9c082/base/bpoint/point.go (about) 1 package bpoint 2 3 import "github.com/songzhibin97/go-baseutils/base/breflect" 4 5 func ToPoint[T any](v T) *T { 6 if breflect.IsNil(v) { 7 return nil 8 } 9 return &v 10 } 11 12 func FromPoint[T any](v *T) T { 13 var zero T 14 return FromPointOrDefaultIfNil(v, zero) 15 } 16 17 func FromPointOrDefaultIfNil[T any](v *T, defaultValue T) T { 18 if v == nil || breflect.IsNil(v) { 19 return defaultValue 20 } 21 return *v 22 }