forked from firecracker-microvm/firecracker-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpointer_helpers.go
61 lines (49 loc) · 1.11 KB
/
pointer_helpers.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package firecracker
// BoolValue will return a boolean value. If the pointer is nil, then false
// will be returned.
func BoolValue(b *bool) bool {
if b == nil {
return false
}
return *b
}
// Bool will return a pointer value of the given parameter.
func Bool(b bool) *bool {
return &b
}
// StringValue will return a string value. If the pointer is nil, then an empty
// string will be returned.
func StringValue(str *string) string {
if str == nil {
return ""
}
return *str
}
// String will return a pointer value of the given parameter.
func String(str string) *string {
return &str
}
// Int64 will return a pointer value of the given parameter.
func Int64(v int64) *int64 {
return &v
}
// Int64Value will return an int64 value. If the pointer is nil, then zero will
// be returned.
func Int64Value(v *int64) int64 {
if v == nil {
return 0
}
return *v
}
// IntValue will return an int value. If the pointer is nil, zero will be
// returned.
func IntValue(v *int) int {
if v == nil {
return 0
}
return *v
}
// Int will return a pointer value of the given parameters.
func Int(v int) *int {
return &v
}