forked from endobit/wifire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunits_enumer.go
More file actions
78 lines (63 loc) · 1.83 KB
/
Copy pathunits_enumer.go
File metadata and controls
78 lines (63 loc) · 1.83 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
// Code generated by "enumer -type Units -linecomment"; DO NOT EDIT.
package gofire
import (
"fmt"
"strings"
)
const _UnitsName = "celsiusfahrenheit"
var _UnitsIndex = [...]uint8{0, 7, 17}
const _UnitsLowerName = "celsiusfahrenheit"
func (i Units) String() string {
if i < 0 || i >= Units(len(_UnitsIndex)-1) {
return fmt.Sprintf("Units(%d)", i)
}
return _UnitsName[_UnitsIndex[i]:_UnitsIndex[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 _UnitsNoOp() {
var x [1]struct{}
_ = x[UnitsCelsius-(0)]
_ = x[UnitsFahrenheit-(1)]
}
var _UnitsValues = []Units{UnitsCelsius, UnitsFahrenheit}
var _UnitsNameToValueMap = map[string]Units{
_UnitsName[0:7]: UnitsCelsius,
_UnitsLowerName[0:7]: UnitsCelsius,
_UnitsName[7:17]: UnitsFahrenheit,
_UnitsLowerName[7:17]: UnitsFahrenheit,
}
var _UnitsNames = []string{
_UnitsName[0:7],
_UnitsName[7:17],
}
// UnitsString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func UnitsString(s string) (Units, error) {
if val, ok := _UnitsNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _UnitsNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Units values", s)
}
// UnitsValues returns all values of the enum
func UnitsValues() []Units {
return _UnitsValues
}
// UnitsStrings returns a slice of all String values of the enum
func UnitsStrings() []string {
strs := make([]string, len(_UnitsNames))
copy(strs, _UnitsNames)
return strs
}
// IsAUnits returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Units) IsAUnits() bool {
for _, v := range _UnitsValues {
if i == v {
return true
}
}
return false
}