@@ -8,26 +8,21 @@ import (
8
8
)
9
9
10
10
func AutogenerateStructMapEntry (rt reflect.Type ) * AtlasEntry {
11
- return AutogenerateStructMapEntryUsingTags (rt , "refmt" , StructFieldSort_Default )
11
+ return AutogenerateStructMapEntryUsingTags (rt , "refmt" , KeySortMode_Default )
12
12
}
13
13
14
- func AutogenerateStructMapEntryUsingTags (rt reflect.Type , tagName , sorter string ) * AtlasEntry {
14
+ func AutogenerateStructMapEntryUsingTags (rt reflect.Type , tagName string , sorter KeySortMode ) * AtlasEntry {
15
15
entry := & AtlasEntry {
16
16
Type : rt ,
17
17
StructMap : & StructMap {Fields : exploreFields (rt , tagName , sorter )},
18
18
}
19
19
return entry
20
20
}
21
21
22
- const (
23
- StructFieldSort_Default = "default"
24
- StructFieldSort_RFC7049 = "rfc7049"
25
- )
26
-
27
22
// exploreFields returns a list of fields that StructAtlas should recognize for the given type.
28
23
// The algorithm is breadth-first search over the set of structs to include - the top struct
29
24
// and then any reachable anonymous structs.
30
- func exploreFields (rt reflect.Type , tagName string , sorter string ) []StructMapEntry {
25
+ func exploreFields (rt reflect.Type , tagName string , sorter KeySortMode ) []StructMapEntry {
31
26
// Anonymous fields to explore at the current level and the next.
32
27
current := []StructMapEntry {}
33
28
next := []StructMapEntry {{Type : rt }}
@@ -143,9 +138,9 @@ func exploreFields(rt reflect.Type, tagName string, sorter string) []StructMapEn
143
138
144
139
fields = out
145
140
switch sorter {
146
- case StructFieldSort_Default :
141
+ case KeySortMode_Default :
147
142
sort .Sort (StructMapEntry_byFieldRoute (fields ))
148
- case StructFieldSort_RFC7049 :
143
+ case KeySortMode_RFC7049 :
149
144
sort .Sort (StructMapEntry_RFC7049 (fields ))
150
145
default :
151
146
panic ("invalid struct sorter option" )
0 commit comments