11package generator
22
33import (
4+ "fmt"
45 "reflect"
56 "sort"
67 "strings"
@@ -120,7 +121,11 @@ func aliasDisplayName(t *types.Type, knownTypes typeSet) string {
120121 return alias [0 ]
121122 }
122123
123- return typeDisplayName (t .Underlying , knownTypes )
124+ if t .Underlying != nil {
125+ return typeDisplayName (t .Underlying , knownTypes )
126+ }
127+
128+ return ""
124129}
125130
126131// anchorIDForLocalType returns the #anchor string for the local type
@@ -159,6 +164,11 @@ func filterCommentTags(comments []string) []string {
159164 return out
160165}
161166
167+ // hideMember determines if a member is to private
168+ func hideMember (m types.Member ) bool {
169+ return unicode .IsLower (rune (m .Name [0 ]))
170+ }
171+
162172// hideType determines if a type is to private
163173func hideType (t * types.Type ) bool {
164174 return unicode .IsLower (rune (t .Name .Name [0 ]))
@@ -181,6 +191,10 @@ func linkForTypeFunc(knownTypes typeSet) func(t *types.Type) string {
181191// linkForType returns an anchor to the type if it can be generated. returns
182192// empty string if it is not a local type or unrecognized external type.
183193func linkForType (t * types.Type , knownTypes typeSet ) string {
194+ if t == nil {
195+ return ""
196+ }
197+
184198 t = tryDereference (t ) // dereference kind=Pointer
185199
186200 if knownTypes .has (t ) {
@@ -242,8 +256,8 @@ func typeDisplayName(t *types.Type, knownTypes typeSet) string {
242256 types .Builtin :
243257 // noop
244258 case types .Map :
245- // return original name
246- return t . Name .Name
259+ // construct map based on element name
260+ return fmt . Sprintf ( "map[%s]%s" , t . Key . Name .Name , s )
247261 default :
248262 klog .Fatalf ("type %s has kind=%v which is unhandled" , t .Name , t .Kind )
249263 }
@@ -284,6 +298,17 @@ func typeReferences(t *types.Type, references map[*types.Type][]*types.Type, kno
284298 return out
285299}
286300
301+ // visibleMembers filters the members to only those that are exported
302+ func visibleMembers (in []types.Member ) []types.Member {
303+ var out []types.Member
304+ for _ , t := range in {
305+ if ! hideMember (t ) {
306+ out = append (out , t )
307+ }
308+ }
309+ return out
310+ }
311+
287312// visibleTypes filters the types to only those that are exported
288313func visibleTypes (in []* types.Type ) []* types.Type {
289314 var out []* types.Type
0 commit comments