fix: refs
This commit is contained in:
14
server/refs/bool.go
Normal file
14
server/refs/bool.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package refs
|
||||
|
||||
// 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 {
|
||||
if r == nil {
|
||||
return false
|
||||
}
|
||||
return *r
|
||||
}
|
14
server/refs/int.go
Normal file
14
server/refs/int.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package refs
|
||||
|
||||
// NewInt64Ref returns a reference to a int64 with given value
|
||||
func NewInt64Ref(v int64) *int64 {
|
||||
return &v
|
||||
}
|
||||
|
||||
// Int64Value returns the value of the given bool ref
|
||||
func Int64Value(r *int64) int64 {
|
||||
if r == nil {
|
||||
return 0
|
||||
}
|
||||
return *r
|
||||
}
|
19
server/refs/string.go
Normal file
19
server/refs/string.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package refs
|
||||
|
||||
// NewStringRef returns a reference to a string with given value
|
||||
func NewStringRef(v string) *string {
|
||||
return &v
|
||||
}
|
||||
|
||||
// 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 ""
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user