authorizer/server/utils/refs.go

31 lines
587 B
Go
Raw Permalink Normal View History

2022-05-31 07:41:54 +00:00
package utils
// NewStringRef returns a reference to a string with given value
func NewStringRef(v string) *string {
return &v
}
2022-07-10 16:19:33 +00:00
// StringValue returns the value of the given string ref
func StringValue(r *string, defaultValue ...string) string {
if r != nil {
return *r
}
if len(defaultValue) > 0 {
return defaultValue[0]
}
return ""
}
// NewBoolRef returns a reference to a bool with given value
func NewBoolRef(v bool) *bool {
return &v
}
// BoolValue returns the value of the given bool ref
func BoolValue(r *bool) bool {
2022-07-11 14:10:54 +00:00
if r == nil {
2022-07-10 16:19:33 +00:00
return false
}
return *r
}