forked from equinix/ne-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
43 lines (37 loc) · 767 Bytes
/
util.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
42
43
package ne
//String returns pointer to a given string value
func String(s string) *string {
return &s
}
//StringValue returns the value of a given string pointer
//or empty string if the pointer is nil
func StringValue(s *string) string {
if s != nil {
return *s
}
return ""
}
//Int returns pointer to a given int value
func Int(i int) *int {
return &i
}
//IntValue returns the value of a given int pointer
//or 0 if the pointer is nil
func IntValue(i *int) int {
if i != nil {
return *i
}
return 0
}
//Bool returns pointer to a given bool value
func Bool(b bool) *bool {
return &b
}
//BoolValue returns the value of a given bool pointer
//or false if the pointer is nil
func BoolValue(b *bool) bool {
if b != nil {
return *b
}
return false
}