/
utils.go
87 lines (69 loc) · 1.65 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package succubus
import (
"regexp"
"unicode"
)
// hasUpper
// It returns whether container upper case or not
func hasUpper(s string) (ok bool) {
for _, r := range s {
if unicode.IsLetter(r) && unicode.IsUpper(r) {
return true
}
}
return false
}
// hasLower
// It returns whether container lower case or not
func hasLower(s string) (ok bool) {
for _, r := range s {
if unicode.IsLetter(r) && unicode.IsLower(r) {
return true
}
}
return false
}
// removeEmptyStrings - Use this to remove empty string values inside an array.
// https://gist.github.com/johnpili/84c3064d30a9b041c87e43ba4bcb63a2
// This happens when allocation is bigger and empty
func removeEmptyStrings(s []string) []string {
var r []string
for _, str := range s {
if str != "" {
r = append(r, str)
}
}
return r
}
// copyMap
// It returns
func copyMap(origin map[string][]string) (dest map[string][]string, fail error) {
dest = make(map[string][]string)
for key, value := range origin {
dest[key] = value
}
return dest, fail
}
// keysOf
// It returns
func keysOf(origin map[string]*Task) (keys []string, fail error) {
keys = make([]string, len(origin))
index := 0
for key, _ := range origin {
keys[index] = key
index += 1
}
return keys, fail
}
// isSemanticVersion
// It returns whether or not is Semantic Version
func isSemanticVersion(origin string) (ok bool) {
condtion, _ := regexp.Compile(`\d+.\d+.\d*`)
return condtion.MatchString(origin)
}
// isCalendarVersion
// It returns whether or not is Semantic Version
func isCalendarVersion(origin string) (ok bool) {
condtion, _ := regexp.Compile(`\d{2}.\d{2}.\d*`)
return condtion.MatchString(origin)
}