-
Notifications
You must be signed in to change notification settings - Fork 0
/
strings.go
74 lines (63 loc) · 1.36 KB
/
strings.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
package main
import (
"fmt"
"strconv"
)
// IsStringHelpArgument: Returns true if given string is a help argument
func IsStringHelpArgument(_theString string) bool {
isHelpArgument := false
if len(_theString) > 0 {
switch _theString {
case "?":
isHelpArgument = true
case "/?":
isHelpArgument = true
case "-?":
isHelpArgument = true
case "--?":
isHelpArgument = true
case "h":
isHelpArgument = true
case "/h":
isHelpArgument = true
case "-h":
isHelpArgument = true
case "--h":
isHelpArgument = true
case "help":
isHelpArgument = true
case "/help":
isHelpArgument = true
case "-help":
isHelpArgument = true
case "--help":
isHelpArgument = true
}
} else {
fmt.Println(fmt.Sprintf(UI_ParameterInvalid, GetFunctionName()), "_theString:", _theString)
}
return isHelpArgument
}
// CommaFormat: Adds commas for every thousand to give number and returns it as a string
func CommaFormat(_number int64) string {
in := strconv.FormatInt(_number, 10)
numOfDigits := len(in)
if _number < 0 {
numOfDigits--
}
numOfCommas := (numOfDigits - 1) / 3
out := make([]byte, len(in)+numOfCommas)
if _number < 0 {
in, out[0] = in[1:], '-'
}
for i, j, k := len(in)-1, len(out)-1, 0; ; i, j = i-1, j-1 {
out[j] = in[i]
if i == 0 {
return string(out)
}
if k++; k == 3 {
j, k = j-1, 0
out[j] = ','
}
}
}