-
Notifications
You must be signed in to change notification settings - Fork 456
/
outformat_enumer.go
102 lines (85 loc) · 2.82 KB
/
outformat_enumer.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Code generated by "enumer -type OutFormat -linecomment -text"; DO NOT EDIT.
package profile
import (
"fmt"
"strings"
)
const _OutFormatName = "unknownraw.tar.gz.xz.gz"
var _OutFormatIndex = [...]uint8{0, 7, 10, 17, 20, 23}
const _OutFormatLowerName = "unknownraw.tar.gz.xz.gz"
func (i OutFormat) String() string {
if i < 0 || i >= OutFormat(len(_OutFormatIndex)-1) {
return fmt.Sprintf("OutFormat(%d)", i)
}
return _OutFormatName[_OutFormatIndex[i]:_OutFormatIndex[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 _OutFormatNoOp() {
var x [1]struct{}
_ = x[OutFormatUnknown-(0)]
_ = x[OutFormatRaw-(1)]
_ = x[OutFormatTar-(2)]
_ = x[OutFormatXZ-(3)]
_ = x[OutFormatGZ-(4)]
}
var _OutFormatValues = []OutFormat{OutFormatUnknown, OutFormatRaw, OutFormatTar, OutFormatXZ, OutFormatGZ}
var _OutFormatNameToValueMap = map[string]OutFormat{
_OutFormatName[0:7]: OutFormatUnknown,
_OutFormatLowerName[0:7]: OutFormatUnknown,
_OutFormatName[7:10]: OutFormatRaw,
_OutFormatLowerName[7:10]: OutFormatRaw,
_OutFormatName[10:17]: OutFormatTar,
_OutFormatLowerName[10:17]: OutFormatTar,
_OutFormatName[17:20]: OutFormatXZ,
_OutFormatLowerName[17:20]: OutFormatXZ,
_OutFormatName[20:23]: OutFormatGZ,
_OutFormatLowerName[20:23]: OutFormatGZ,
}
var _OutFormatNames = []string{
_OutFormatName[0:7],
_OutFormatName[7:10],
_OutFormatName[10:17],
_OutFormatName[17:20],
_OutFormatName[20:23],
}
// OutFormatString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func OutFormatString(s string) (OutFormat, error) {
if val, ok := _OutFormatNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _OutFormatNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to OutFormat values", s)
}
// OutFormatValues returns all values of the enum
func OutFormatValues() []OutFormat {
return _OutFormatValues
}
// OutFormatStrings returns a slice of all String values of the enum
func OutFormatStrings() []string {
strs := make([]string, len(_OutFormatNames))
copy(strs, _OutFormatNames)
return strs
}
// IsAOutFormat returns "true" if the value is listed in the enum definition. "false" otherwise
func (i OutFormat) IsAOutFormat() bool {
for _, v := range _OutFormatValues {
if i == v {
return true
}
}
return false
}
// MarshalText implements the encoding.TextMarshaler interface for OutFormat
func (i OutFormat) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
// UnmarshalText implements the encoding.TextUnmarshaler interface for OutFormat
func (i *OutFormat) UnmarshalText(text []byte) error {
var err error
*i, err = OutFormatString(string(text))
return err
}