-
Notifications
You must be signed in to change notification settings - Fork 57
/
diff_base_enum.go
87 lines (76 loc) · 2.15 KB
/
diff_base_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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Code generated by go-enum DO NOT EDIT.
// Version: example
// Revision: example
// Build Date: example
// Built By: example
//go:build example
// +build example
package example
import (
"errors"
"fmt"
)
const (
// DiffBaseB3 is a DiffBase of type B3.
DiffBaseB3 DiffBase = iota + 3
// DiffBaseB4 is a DiffBase of type B4.
DiffBaseB4
// DiffBaseB5 is a DiffBase of type B5.
DiffBaseB5
// DiffBaseB6 is a DiffBase of type B6.
DiffBaseB6
// DiffBaseB7 is a DiffBase of type B7.
DiffBaseB7
// DiffBaseB8 is a DiffBase of type B8.
DiffBaseB8
// DiffBaseB9 is a DiffBase of type B9.
DiffBaseB9
// DiffBaseB10 is a DiffBase of type B10.
DiffBaseB10 DiffBase = iota + 4
// DiffBaseB11 is a DiffBase of type B11.
DiffBaseB11 DiffBase = iota + 35
)
var ErrInvalidDiffBase = errors.New("not a valid DiffBase")
const _DiffBaseName = "b3b4b5b6b7b8b9b10b11"
var _DiffBaseMap = map[DiffBase]string{
DiffBaseB3: _DiffBaseName[0:2],
DiffBaseB4: _DiffBaseName[2:4],
DiffBaseB5: _DiffBaseName[4:6],
DiffBaseB6: _DiffBaseName[6:8],
DiffBaseB7: _DiffBaseName[8:10],
DiffBaseB8: _DiffBaseName[10:12],
DiffBaseB9: _DiffBaseName[12:14],
DiffBaseB10: _DiffBaseName[14:17],
DiffBaseB11: _DiffBaseName[17:20],
}
// String implements the Stringer interface.
func (x DiffBase) String() string {
if str, ok := _DiffBaseMap[x]; ok {
return str
}
return fmt.Sprintf("DiffBase(%d)", x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x DiffBase) IsValid() bool {
_, ok := _DiffBaseMap[x]
return ok
}
var _DiffBaseValue = map[string]DiffBase{
_DiffBaseName[0:2]: DiffBaseB3,
_DiffBaseName[2:4]: DiffBaseB4,
_DiffBaseName[4:6]: DiffBaseB5,
_DiffBaseName[6:8]: DiffBaseB6,
_DiffBaseName[8:10]: DiffBaseB7,
_DiffBaseName[10:12]: DiffBaseB8,
_DiffBaseName[12:14]: DiffBaseB9,
_DiffBaseName[14:17]: DiffBaseB10,
_DiffBaseName[17:20]: DiffBaseB11,
}
// ParseDiffBase attempts to convert a string to a DiffBase.
func ParseDiffBase(name string) (DiffBase, error) {
if x, ok := _DiffBaseValue[name]; ok {
return x, nil
}
return DiffBase(0), fmt.Errorf("%s is %w", name, ErrInvalidDiffBase)
}