/
strconv_enum.go
71 lines (61 loc) · 1.78 KB
/
strconv_enum.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
// Code generated by go-enum DO NOT EDIT.
// Version:
// Revision:
// Build Date:
// Built By:
package enigma
import (
"fmt"
"strings"
)
const (
// StrConvPlain is a StrConv of type Plain.
StrConvPlain StrConv = iota
// StrConvBase64 is a StrConv of type Base64.
StrConvBase64
// StrConvHex is a StrConv of type Hex.
StrConvHex
)
const _StrConvName = "plainbase64hex"
var _StrConvNames = []string{
_StrConvName[0:5],
_StrConvName[5:11],
_StrConvName[11:14],
}
// StrConvNames returns a list of possible string values of StrConv.
func StrConvNames() []string {
tmp := make([]string, len(_StrConvNames))
copy(tmp, _StrConvNames)
return tmp
}
var _StrConvMap = map[StrConv]string{
StrConvPlain: _StrConvName[0:5],
StrConvBase64: _StrConvName[5:11],
StrConvHex: _StrConvName[11:14],
}
// String implements the Stringer interface.
func (x StrConv) String() string {
if str, ok := _StrConvMap[x]; ok {
return str
}
return fmt.Sprintf("StrConv(%d)", x)
}
var _StrConvValue = map[string]StrConv{
_StrConvName[0:5]: StrConvPlain,
strings.ToLower(_StrConvName[0:5]): StrConvPlain,
_StrConvName[5:11]: StrConvBase64,
strings.ToLower(_StrConvName[5:11]): StrConvBase64,
_StrConvName[11:14]: StrConvHex,
strings.ToLower(_StrConvName[11:14]): StrConvHex,
}
// ParseStrConv attempts to convert a string to a StrConv.
func ParseStrConv(name string) (StrConv, error) {
if x, ok := _StrConvValue[name]; ok {
return x, nil
}
// Case insensitive parse, do a separate lookup to prevent unnecessary cost of lowercasing a string if we don't need to.
if x, ok := _StrConvValue[strings.ToLower(name)]; ok {
return x, nil
}
return StrConv(0), fmt.Errorf("%s is not a valid StrConv, try [%s]", name, strings.Join(_StrConvNames, ", "))
}