-
Notifications
You must be signed in to change notification settings - Fork 57
/
user_template_enum.go
78 lines (65 loc) · 1.81 KB
/
user_template_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
// 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 (
// OceanColorCerulean is a OceanColor of type Cerulean.
OceanColorCerulean OceanColor = iota
// OceanColorBlue is a OceanColor of type Blue.
OceanColorBlue
// OceanColorGreen is a OceanColor of type Green.
OceanColorGreen
)
var ErrInvalidOceanColor = errors.New("not a valid OceanColor")
const _OceanColorName = "CeruleanBlueGreen"
var _OceanColorMap = map[OceanColor]string{
OceanColorCerulean: _OceanColorName[0:8],
OceanColorBlue: _OceanColorName[8:12],
OceanColorGreen: _OceanColorName[12:17],
}
// String implements the Stringer interface.
func (x OceanColor) String() string {
if str, ok := _OceanColorMap[x]; ok {
return str
}
return fmt.Sprintf("OceanColor(%d)", x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x OceanColor) IsValid() bool {
_, ok := _OceanColorMap[x]
return ok
}
var _OceanColorValue = map[string]OceanColor{
_OceanColorName[0:8]: OceanColorCerulean,
_OceanColorName[8:12]: OceanColorBlue,
_OceanColorName[12:17]: OceanColorGreen,
}
// ParseOceanColor attempts to convert a string to a OceanColor.
func ParseOceanColor(name string) (OceanColor, error) {
if x, ok := _OceanColorValue[name]; ok {
return x, nil
}
return OceanColor(0), fmt.Errorf("%s is %w", name, ErrInvalidOceanColor)
}
func ParseOceanColorGlobbedExample() bool {
return true
}
func ParseOceanColorGlobbedExample2() bool {
return true
}
// Additional template
func ParseOceanColorExample() bool {
return true
}
func ParseOceanColorDescription() string {
return `OceanColor is an enumeration of ocean colors that are allowed.`
}