-
Notifications
You must be signed in to change notification settings - Fork 2
/
enum_status.go
69 lines (56 loc) · 1.35 KB
/
enum_status.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
// Code generated by "enumerator -type Status -linecomment -trimprefix"; DO NOT EDIT.
package actor
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[StatusActive-0]
_ = x[StatusSuspended-1]
}
const _Status_name = "activesuspended"
var _Status_index = [...]uint8{0, 6, 15}
func (i Status) String() string {
if i >= Status(len(_Status_index)-1) {
return "Status(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _Status_name[_Status_index[i]:_Status_index[i+1]]
}
func (i Status) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
func (i *Status) UnmarshalText(text []byte) error {
val, err := ParseStatus(string(text))
if err != nil {
return err
}
*i = val
return nil
}
func (i Status) IsActive() bool {
return i == StatusActive
}
func (i Status) IsSuspended() bool {
return i == StatusSuspended
}
func ParseStatus(s string) (Status, error) {
switch s {
case "active":
return StatusActive, nil
case "suspended":
return StatusSuspended, nil
default:
return Status(0), fmt.Errorf("invalid Status '%s'", s)
}
}
type StatusOptions struct {
Active Status
Suspended Status
}
var StatusValues = StatusOptions{
Active: StatusActive,
Suspended: StatusSuspended,
}