forked from IBM/ibmcloud-storage-volume-lib
/
data_utils.go
26 lines (23 loc) · 926 Bytes
/
data_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
/*******************************************************************************
* IBM Confidential
* OCO Source Materials
* IBM Cloud Container Service, 5737-D43
* (C) Copyright IBM Corp. 2018 All Rights Reserved.
* The source code for this program is not published or otherwise divested of
* its trade secrets, irrespective of what has been deposited with
* the U.S. Copyright Office.
******************************************************************************/
package util
// SafeStringValue returns the referenced string value, treating nil as equivalent to "".
// It is intended as a type-safe and nil-safe test for empty values in data fields of
func SafeStringValue(s *string) string {
if s == nil {
return ""
}
return *s
}
// StringHasValue returns true if the argument is neither nil nor a pointer to the
// zero/empty string.
func StringHasValue(s *string) bool {
return s != nil && *s != ""
}