-
Notifications
You must be signed in to change notification settings - Fork 0
/
enclose.go
44 lines (39 loc) · 923 Bytes
/
enclose.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
package text
type enclosure int
const (
parenthesis enclosure = iota
brackets
braces
angles
)
func (symbol enclosure) Open() string {
switch symbol {
case parenthesis:
return "("
case brackets:
return "["
case braces:
return "{"
case angles:
return "<"
}
return ""
}
func (symbol enclosure) Close() string {
switch symbol {
case parenthesis:
return ")"
case brackets:
return "]"
case braces:
return "}"
case angles:
return ">"
}
return ""
}
func Enclose(symbol enclosure, text string) string { return symbol.Open() + text + symbol.Close() }
func Parenthesis(text string) string { return Enclose(parenthesis, text) }
func Brackets(text string) string { return Enclose(brackets, text) }
func Braces(text string) string { return Enclose(braces, text) }
func Angles(text string) string { return Enclose(angles, text) }