-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgen_typenames.go
39 lines (35 loc) · 949 Bytes
/
gen_typenames.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
package bebop
func simpleGoString(simple string, settings GenerateSettings) string {
if simple == typeGUID {
return "[16]byte"
}
if simple == typeDate {
return "time.Time"
}
if alias, ok := settings.importTypeAliases[simple]; ok {
return alias
}
return simple
}
func (ft FieldType) goString(settings GenerateSettings) string {
if ft.Map != nil {
return "map[" + simpleGoString(ft.Map.Key, settings) + "]" + ft.Map.Value.goString(settings)
}
if ft.Array != nil {
return "[]" + ft.Array.goString(settings)
}
if settings.PrivateDefinitions {
return unexposeName(simpleGoString(ft.Simple, settings))
}
return simpleGoString(ft.Simple, settings)
}
func (mt MapType) goString(settings GenerateSettings) string {
return "map[" + simpleGoString(mt.Key, settings) + "]" + mt.Value.goString(settings)
}
func (uf UnionField) name() string {
if uf.Message != nil {
return uf.Message.Name
} else {
return uf.Struct.Name
}
}