-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.go
More file actions
31 lines (25 loc) · 706 Bytes
/
string.go
File metadata and controls
31 lines (25 loc) · 706 Bytes
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
package pointerhelpers
// StringHelper contains all String related
// pointer helpers
type StringHelper struct{}
// String returns a pointer to the string value passed in.
func String(v string) *string {
return &v
}
// String returns a pointer to the string value passed in.
func (s *StringHelper) String(v string) *string {
return String(v)
}
// StringValue returns the value of the string pointer passed in or
// "" if the pointer is nil.
func StringValue(v *string) string {
if v != nil {
return *v
}
return ""
}
// StringValue returns the value of the string pointer passed in or
// "" if the pointer is nil.
func (s *StringHelper) StringValue(v *string) string {
return StringValue(v)
}