-
Notifications
You must be signed in to change notification settings - Fork 30
/
service_string.go
74 lines (59 loc) · 1.78 KB
/
service_string.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
// Code generated by "enumer -type=Service -output=service_string.go -linecomment=true"; DO NOT EDIT.
package google
import (
"fmt"
"strings"
)
const _ServiceName = "Compute Engine"
var _ServiceIndex = [...]uint8{0, 14}
const _ServiceLowerName = "compute engine"
func (i Service) String() string {
if i >= Service(len(_ServiceIndex)-1) {
return fmt.Sprintf("Service(%d)", i)
}
return _ServiceName[_ServiceIndex[i]:_ServiceIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _ServiceNoOp() {
var x [1]struct{}
_ = x[ComputeEngine-(0)]
}
var _ServiceValues = []Service{ComputeEngine}
var _ServiceNameToValueMap = map[string]Service{
_ServiceName[0:14]: ComputeEngine,
_ServiceLowerName[0:14]: ComputeEngine,
}
var _ServiceNames = []string{
_ServiceName[0:14],
}
// ServiceString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ServiceString(s string) (Service, error) {
if val, ok := _ServiceNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _ServiceNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Service values", s)
}
// ServiceValues returns all values of the enum
func ServiceValues() []Service {
return _ServiceValues
}
// ServiceStrings returns a slice of all String values of the enum
func ServiceStrings() []string {
strs := make([]string, len(_ServiceNames))
copy(strs, _ServiceNames)
return strs
}
// IsAService returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Service) IsAService() bool {
for _, v := range _ServiceValues {
if i == v {
return true
}
}
return false
}