-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathapp_enum.go
99 lines (85 loc) · 2.49 KB
/
app_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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Code generated by go-enum DO NOT EDIT.
// Version:
// Revision:
// Build Date:
// Built By:
package launcher
import (
"fmt"
"strings"
)
const (
// AppStatusNotFound is a AppStatus of type NotFound.
AppStatusNotFound AppStatus = iota
// AppStatusCreated is a AppStatus of type Created.
AppStatusCreated
// AppStatusRunning is a AppStatus of type Running.
AppStatusRunning
// AppStatusWarning is a AppStatus of type Warning.
AppStatusWarning
// AppStatusStopped is a AppStatus of type Stopped.
AppStatusStopped
)
var ErrInvalidAppStatus = fmt.Errorf("not a valid AppStatus, try [%s]", strings.Join(_AppStatusNames, ", "))
const _AppStatusName = "NotFoundCreatedRunningWarningStopped"
var _AppStatusNames = []string{
_AppStatusName[0:8],
_AppStatusName[8:15],
_AppStatusName[15:22],
_AppStatusName[22:29],
_AppStatusName[29:36],
}
// AppStatusNames returns a list of possible string values of AppStatus.
func AppStatusNames() []string {
tmp := make([]string, len(_AppStatusNames))
copy(tmp, _AppStatusNames)
return tmp
}
var _AppStatusMap = map[AppStatus]string{
AppStatusNotFound: _AppStatusName[0:8],
AppStatusCreated: _AppStatusName[8:15],
AppStatusRunning: _AppStatusName[15:22],
AppStatusWarning: _AppStatusName[22:29],
AppStatusStopped: _AppStatusName[29:36],
}
// String implements the Stringer interface.
func (x AppStatus) String() string {
if str, ok := _AppStatusMap[x]; ok {
return str
}
return fmt.Sprintf("AppStatus(%d)", x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x AppStatus) IsValid() bool {
_, ok := _AppStatusMap[x]
return ok
}
var _AppStatusValue = map[string]AppStatus{
_AppStatusName[0:8]: AppStatusNotFound,
_AppStatusName[8:15]: AppStatusCreated,
_AppStatusName[15:22]: AppStatusRunning,
_AppStatusName[22:29]: AppStatusWarning,
_AppStatusName[29:36]: AppStatusStopped,
}
// ParseAppStatus attempts to convert a string to a AppStatus.
func ParseAppStatus(name string) (AppStatus, error) {
if x, ok := _AppStatusValue[name]; ok {
return x, nil
}
return AppStatus(0), fmt.Errorf("%s is %w", name, ErrInvalidAppStatus)
}
// MarshalText implements the text marshaller method.
func (x AppStatus) MarshalText() ([]byte, error) {
return []byte(x.String()), nil
}
// UnmarshalText implements the text unmarshaller method.
func (x *AppStatus) UnmarshalText(text []byte) error {
name := string(text)
tmp, err := ParseAppStatus(name)
if err != nil {
return err
}
*x = tmp
return nil
}