-
Notifications
You must be signed in to change notification settings - Fork 0
/
bool.go
41 lines (34 loc) · 882 Bytes
/
bool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package pointerhelpers
// BoolHelper contains all Bool related
// pointer helpers
type BoolHelper struct {
}
// Bool returns a pointer to the Bool value passed in.
func Bool(v bool) *bool {
return &v
}
// Bool returns a pointer to the bool value passed in.
func (b *BoolHelper) Bool(v bool) *bool {
return Bool(v)
}
// BoolValue returns the value of the bool pointer passed in or
// 0 if the pointer is nil.
func BoolValue(v *bool) bool {
if v != nil {
return *v
}
return false
}
// BoolValue returns the value of the bool pointer passed in or
// 0 if the pointer is nil.
func (b *BoolHelper) BoolValue(v *bool) bool {
return BoolValue(v)
}
// BoolIsUnset returns true if the pointer is nil
func BoolIsUnset(v *bool) bool {
return v == nil
}
// BoolIsUnset returns true if the pointer is nil
func (b *BoolHelper) BoolIsUnset(v *bool) bool {
return BoolIsUnset(v)
}