mirror of https://github.com/kubernetes/kops.git
Merge pull request #14595 from hakman/generics_add_alternatives
Add generics alternatives for fi.Bool/Float*/Int*/String*()
This commit is contained in:
commit
7fe820e96d
|
|
@ -23,6 +23,19 @@ import (
|
|||
"strconv"
|
||||
)
|
||||
|
||||
// PtrTo returns a pointer to a copy of any value.
|
||||
func PtrTo[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
||||
// ValueOf returns the value of a pointer or its zero value
|
||||
func ValueOf[T any](v *T) T {
|
||||
if v == nil {
|
||||
return *new(T)
|
||||
}
|
||||
return *v
|
||||
}
|
||||
|
||||
func StringValue(s *string) string {
|
||||
if s == nil {
|
||||
return ""
|
||||
|
|
|
|||
Loading…
Reference in New Issue