-
Notifications
You must be signed in to change notification settings - Fork 2
/
enum_lang.go
77 lines (63 loc) · 1.24 KB
/
enum_lang.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
// Code generated by "enumerator -type Lang -linecomment -empty"; DO NOT EDIT.
package localize
import (
"fmt"
"strconv"
)
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[En-1]
_ = x[Cy-2]
}
const _Lang_name = "ency"
var _Lang_index = [...]uint8{0, 2, 4}
func (i Lang) String() string {
if i == 0 {
return ""
}
i -= 1
if i >= Lang(len(_Lang_index)-1) {
return "Lang(" + strconv.FormatInt(int64(i+1), 10) + ")"
}
return _Lang_name[_Lang_index[i]:_Lang_index[i+1]]
}
func (i Lang) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
func (i *Lang) UnmarshalText(text []byte) error {
val, err := ParseLang(string(text))
if err != nil {
return err
}
*i = val
return nil
}
func (i Lang) IsEn() bool {
return i == En
}
func (i Lang) IsCy() bool {
return i == Cy
}
func ParseLang(s string) (Lang, error) {
switch s {
case "en":
return En, nil
case "cy":
return Cy, nil
default:
return Lang(0), fmt.Errorf("invalid Lang '%s'", s)
}
}
type LangOptions struct {
En Lang
Cy Lang
}
var LangValues = LangOptions{
En: En,
Cy: Cy,
}
func (i Lang) Empty() bool {
return i == Lang(0)
}