-
Notifications
You must be signed in to change notification settings - Fork 57
/
force_upper_enum.go
59 lines (48 loc) · 1.5 KB
/
force_upper_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
// 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 (
// ForceUpperTypeDataSwap is a ForceUpperType of type DataSwap.
ForceUpperTypeDataSwap ForceUpperType = iota
// ForceUpperTypeBootNode is a ForceUpperType of type BootNode.
ForceUpperTypeBootNode
)
var ErrInvalidForceUpperType = errors.New("not a valid ForceUpperType")
const _ForceUpperTypeName = "DATASWAPBOOTNODE"
var _ForceUpperTypeMap = map[ForceUpperType]string{
ForceUpperTypeDataSwap: _ForceUpperTypeName[0:8],
ForceUpperTypeBootNode: _ForceUpperTypeName[8:16],
}
// String implements the Stringer interface.
func (x ForceUpperType) String() string {
if str, ok := _ForceUpperTypeMap[x]; ok {
return str
}
return fmt.Sprintf("ForceUpperType(%d)", x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x ForceUpperType) IsValid() bool {
_, ok := _ForceUpperTypeMap[x]
return ok
}
var _ForceUpperTypeValue = map[string]ForceUpperType{
_ForceUpperTypeName[0:8]: ForceUpperTypeDataSwap,
_ForceUpperTypeName[8:16]: ForceUpperTypeBootNode,
}
// ParseForceUpperType attempts to convert a string to a ForceUpperType.
func ParseForceUpperType(name string) (ForceUpperType, error) {
if x, ok := _ForceUpperTypeValue[name]; ok {
return x, nil
}
return ForceUpperType(0), fmt.Errorf("%s is %w", name, ErrInvalidForceUpperType)
}