forked from kevholditch/gokong
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.go
51 lines (43 loc) · 758 Bytes
/
convert.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
package gokong
func String(v string) *string {
return &v
}
func Bool(v bool) *bool {
return &v
}
func Int(v int) *int {
return &v
}
func ToId(v string) *Id {
id := Id(v)
return &id
}
func IdToString(v *Id) string {
if v == nil {
return ""
}
return string(*v)
}
func IpPortSliceSlice(src []IpPort) []*IpPort {
dst := make([]*IpPort, len(src))
for i := 0; i < len(src); i++ {
dst[i] = &(src[i])
}
return dst
}
func StringSlice(src []string) []*string {
dst := make([]*string, len(src))
for i := 0; i < len(src); i++ {
dst[i] = &(src[i])
}
return dst
}
func StringValueSlice(src []*string) []string {
dst := make([]string, len(src))
for i := 0; i < len(src); i++ {
if src[i] != nil {
dst[i] = *(src[i])
}
}
return dst
}