/
gong_enum.go
61 lines (52 loc) · 1.29 KB
/
gong_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
// generated by ModelGongEnumFileTemplate
package models
// insertion point of enum utility functions
// Utility function for EditorType
// if enum values are string, it is stored with the value
// if enum values are int, they are stored with the code of the value
func (editortype EditorType) ToString() (res string) {
// migration of former implementation of enum
switch editortype {
// insertion code per enum code
case EDITOR_ADDER:
res = "EDITOR_ADDER"
case EDITOR_UPDATER:
res = "EDITOR_UPDATER"
}
return
}
func (editortype *EditorType) FromString(input string) (err error) {
switch input {
// insertion code per enum code
case "EDITOR_ADDER":
*editortype = EDITOR_ADDER
case "EDITOR_UPDATER":
*editortype = EDITOR_UPDATER
default:
return errUnkownEnum
}
return
}
func (editortype *EditorType) FromCodeString(input string) (err error) {
switch input {
// insertion code per enum code
case "EDITOR_ADDER":
*editortype = EDITOR_ADDER
case "EDITOR_UPDATER":
*editortype = EDITOR_UPDATER
default:
return errUnkownEnum
}
return
}
func (editortype *EditorType) ToCodeString() (res string) {
switch *editortype {
// insertion code per enum code
case EDITOR_ADDER:
res = "EDITOR_ADDER"
case EDITOR_UPDATER:
res = "EDITOR_UPDATER"
}
return
}
// Last line of the template