-
Notifications
You must be signed in to change notification settings - Fork 7
/
model.go
103 lines (87 loc) · 2.08 KB
/
model.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
100
101
102
103
package gotsrpc
type ScalarType string
const (
ScalarTypeString ScalarType = "string"
ScalarTypeAny ScalarType = "any"
ScalarTypeByte ScalarType = "byte"
ScalarTypeNumber ScalarType = "number"
ScalarTypeBool ScalarType = "bool"
ScalarTypeNone ScalarType = ""
)
type JSONInfo struct {
Name string
Type string
Union bool
Inline bool
OmitEmpty bool
Ignore bool
}
type StructType struct {
Name string
Package string
}
type Value struct {
JSONInfo *JSONInfo `json:",omitempty"`
IsError bool `json:",omitempty"`
IsInterface bool `json:",omitempty"`
Scalar *Scalar `json:",omitempty"`
ScalarType ScalarType `json:",omitempty"`
GoScalarType string `json:",omitempty"`
StructType *StructType `json:",omitempty"`
Struct *Struct `json:",omitempty"`
Map *Map `json:",omitempty"`
Array *Array `json:",omitempty"`
IsPtr bool `json:",omitempty"`
}
type Array struct {
Value *Value
}
type Map struct {
Key *Value
Value *Value
KeyType string
KeyGoType string
}
type Field struct {
Value *Value
Name string `json:",omitempty"`
JSONInfo *JSONInfo `json:",omitempty"`
}
type Service struct {
Name string
Methods ServiceMethods
Endpoint string
IsInterface bool
}
type ServiceMethods []*Method
type ServiceList []*Service
func (sm ServiceMethods) Len() int { return len(sm) }
func (sm ServiceMethods) Swap(i, j int) { sm[i], sm[j] = sm[j], sm[i] }
func (sm ServiceMethods) Less(i, j int) bool { return sm[i].Name < sm[j].Name }
type Method struct {
Name string
Args []*Field
Return []*Field
}
type Struct struct {
IsError bool
Package string
Name string
Fields []*Field
UnionFields []*Field
InlineFields []*Field
Map *Map
Array *Array
}
type Scalar struct {
Name string
Package string
Type ScalarType
}
func (st *Scalar) FullName() string {
fullName := st.Package + "." + st.Name
if len(fullName) == 0 {
fullName = st.Name
}
return fullName
}