-
Notifications
You must be signed in to change notification settings - Fork 0
/
suffix.enum.gen.go
54 lines (44 loc) · 1.1 KB
/
suffix.enum.gen.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
// Code generated by https://github.com/expgo/ag DO NOT EDIT.
// Plugins:
// - github.com/expgo/enum
package example
import (
"errors"
"fmt"
)
const (
// SuffixGen is a Suffix of type gen.
SuffixGen Suffix = "gen"
)
var ErrInvalidSuffix = errors.New("not a valid Suffix")
var _SuffixNameMap = map[string]Suffix{
"gen": SuffixGen,
}
// Name is the attribute of Suffix.
func (x Suffix) Name() string {
if v, ok := _SuffixNameMap[string(x)]; ok {
return string(v)
}
return fmt.Sprintf("Suffix(%s).Name", string(x))
}
// Val is the attribute of Suffix.
func (x Suffix) Val() string {
return string(x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x Suffix) IsValid() bool {
_, ok := _SuffixNameMap[string(x)]
return ok
}
// String implements the Stringer interface.
func (x Suffix) String() string {
return x.Name()
}
// ParseSuffix converts a string to a Suffix.
func ParseSuffix(value string) (Suffix, error) {
if x, ok := _SuffixNameMap[value]; ok {
return x, nil
}
return "", fmt.Errorf("%s is %w", value, ErrInvalidSuffix)
}