forked from dmarkham/enumer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trimPrefix.golden
90 lines (77 loc) · 2.3 KB
/
trimPrefix.golden
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
const _DayName = "MondayTuesdayWednesdayThursdayFridaySaturdaySunday"
var _DayIndex = [...]uint8{0, 6, 13, 22, 30, 36, 44, 50}
const _DayLowerName = "mondaytuesdaywednesdaythursdayfridaysaturdaysunday"
func (i Day) String() string {
if i < 0 || i >= Day(len(_DayIndex)-1) {
return fmt.Sprintf("Day(%d)", i)
}
return _DayName[_DayIndex[i]:_DayIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _DayNoOp() {
var x [1]struct{}
_ = x[DayMonday-(0)]
_ = x[DayTuesday-(1)]
_ = x[DayWednesday-(2)]
_ = x[DayThursday-(3)]
_ = x[DayFriday-(4)]
_ = x[DaySaturday-(5)]
_ = x[DaySunday-(6)]
}
var _DayValues = []Day{DayMonday, DayTuesday, DayWednesday, DayThursday, DayFriday, DaySaturday, DaySunday}
var _DayNameToValueMap = map[string]Day{
_DayName[0:6]: DayMonday,
_DayLowerName[0:6]: DayMonday,
_DayName[6:13]: DayTuesday,
_DayLowerName[6:13]: DayTuesday,
_DayName[13:22]: DayWednesday,
_DayLowerName[13:22]: DayWednesday,
_DayName[22:30]: DayThursday,
_DayLowerName[22:30]: DayThursday,
_DayName[30:36]: DayFriday,
_DayLowerName[30:36]: DayFriday,
_DayName[36:44]: DaySaturday,
_DayLowerName[36:44]: DaySaturday,
_DayName[44:50]: DaySunday,
_DayLowerName[44:50]: DaySunday,
}
var _DayNames = []string{
_DayName[0:6],
_DayName[6:13],
_DayName[13:22],
_DayName[22:30],
_DayName[30:36],
_DayName[36:44],
_DayName[44:50],
}
// DayString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func DayString(s string) (Day, error) {
if val, ok := _DayNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _DayNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Day values", s)
}
// DayValues returns all values of the enum
func DayValues() []Day {
return _DayValues
}
// DayStrings returns a slice of all String values of the enum
func DayStrings() []string {
strs := make([]string, len(_DayNames))
copy(strs, _DayNames)
return strs
}
// IsADay returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Day) IsADay() bool {
for _, v := range _DayValues {
if i == v {
return true
}
}
return false
}