-
Notifications
You must be signed in to change notification settings - Fork 98
/
utils.go
42 lines (35 loc) · 1013 Bytes
/
utils.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
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-2019 Datadog, Inc.
package v1alpha1
// NewInt32Pointer returns pointer on a new int32 value instance
func NewInt32Pointer(i int32) *int32 {
return &i
}
// NewInt64Pointer returns pointer on a new int32 value instance
func NewInt64Pointer(i int64) *int64 {
return &i
}
// NewStringPointer returns pointer on a new string value instance
func NewStringPointer(s string) *string {
return &s
}
// NewBoolPointer returns pointer on a new bool value instance
func NewBoolPointer(b bool) *bool {
return &b
}
// BoolValue return the boolean value, false if nil
func BoolValue(b *bool) bool {
if b == nil {
return false
}
return *b
}
// BoolToString return "true" if b == true, else "false"
func BoolToString(b *bool) string {
if BoolValue(b) {
return "true"
}
return "false"
}