update
parent
bc2b92c73b
commit
e42de5e171
19
common.go
19
common.go
|
@ -106,3 +106,22 @@ func UniqueSlice[T comparable](rawSlice []T) []T {
|
||||||
}
|
}
|
||||||
return uniqueSlice
|
return uniqueSlice
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ptr 获取类型指针
|
||||||
|
func Ptr[T any](v T) *T {
|
||||||
|
return &v
|
||||||
|
}
|
||||||
|
|
||||||
|
func StringPtr(v string) *string {
|
||||||
|
if v == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &v
|
||||||
|
}
|
||||||
|
|
||||||
|
func StringVal(v *string) string {
|
||||||
|
if v == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return *v
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue