forked from GreenRaccoon23/bgmysword
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat.go
More file actions
91 lines (80 loc) · 1.29 KB
/
format.go
File metadata and controls
91 lines (80 loc) · 1.29 KB
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
88
89
90
91
package main
import (
"bytes"
"unicode"
)
var (
buffer bytes.Buffer
)
func str(slice []string) (concatenated string) {
for _, s := range slice {
buffer.WriteString(s)
}
concatenated = buffer.String()
buffer.Reset()
return
}
func slc(args ...string) []string {
return args
}
func concat(args ...string) string {
return str(args)
}
func IsNotEmpty(s string) bool {
switch s {
case "":
return false
default:
return true
}
}
func appendCombine(slice []string, args ...string) (combined string) {
appendedSlice := append(slice, args...)
combined = str(appendedSlice)
return
}
func lastLetter(s string) string {
last := len(s) - 1
return string([]rune(s)[last])
}
func suffixSpace(s string) string {
for i, r := range s {
if unicode.IsSpace(r) {
i++
return s[i:]
}
}
return s
}
func suffixHyphenSecond(s string) string {
var foundFirst bool
ss := []byte(s)
for i, b := range ss {
if b == 45 {
switch foundFirst {
case false:
foundFirst = true
case true:
i++
return string(ss[i:])
}
}
}
return s
}
func prefixHyphenSecond(s string) string {
var foundFirst bool
ss := []byte(s)
for i, b := range ss {
if b == 45 {
switch foundFirst {
case false:
foundFirst = true
case true:
i++
return string(ss[:i])
}
}
}
return s
}