From 8c3ecaabb2da2a0263375600313218654b3401f9 Mon Sep 17 00:00:00 2001 From: Evgeny Khabarov Date: Tue, 10 Mar 2020 07:09:35 -0500 Subject: [PATCH] unsupported-field: Deleted unsupported fields from result struct. (#2) --- parser.go | 7 +++---- parser_test.go | 36 ++---------------------------------- 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/parser.go b/parser.go index 2e72676..343bba6 100644 --- a/parser.go +++ b/parser.go @@ -120,6 +120,9 @@ func inspect( } id, fn, _, ptr := typsw(field.Type) + if id == nil { + continue + } if fn != "" { fname = fn @@ -172,10 +175,6 @@ func typsw(fieldType ast.Expr) (id *ast.Ident, fname, typ string, ptr bool) { case *ast.ArrayType: id, fname, typ, ptr = typsw(t.Elt) return - - default: - typ = fmt.Sprintf("%T", t) - fname = fmt.Sprintf("unsupported_%s_%d", typ, t.Pos()) } return } diff --git a/parser_test.go b/parser_test.go index c98f972..dc51a45 100644 --- a/parser_test.go +++ b/parser_test.go @@ -307,16 +307,7 @@ var _ = Describe("Parser", func() { Expect(str).To(gs.MatchAllFields(gs.Fields{ "Package": Equal("whatever"), "Structs": gs.MatchAllKeys(gs.Keys{ - - "UnsupportedSlices": gs.MatchAllKeys(gs.Keys{ - - "unsupported_*ast.MapType_1024": gs.MatchAllFields(gs.Fields{ - "Type": BeNil(), - "IsPointer": BeFalse(), - "Tags": BeZero(), - "Ord": Equal(uint8(0)), - }), - }), + "UnsupportedSlices": HaveLen(0), }), })) }) @@ -369,30 +360,7 @@ var _ = Describe("Parser", func() { Expect(str).To(gs.MatchAllFields(gs.Fields{ "Package": Equal("whatever"), "Structs": gs.MatchAllKeys(gs.Keys{ - - "UnsupportedTypes": gs.MatchAllKeys(gs.Keys{ - - "unsupported_*ast.FuncType_659": gs.MatchAllFields(gs.Fields{ - "Type": BeNil(), - "IsPointer": BeFalse(), - "Tags": BeZero(), - "Ord": Equal(uint8(0)), - }), - - "unsupported_*ast.MapType_671": gs.MatchAllFields(gs.Fields{ - "Type": BeNil(), - "IsPointer": BeFalse(), - "Tags": BeZero(), - "Ord": Equal(uint8(1)), - }), - - "unsupported_*ast.MapType_692": gs.MatchAllFields(gs.Fields{ - "Type": BeNil(), - "IsPointer": BeTrue(), - "Tags": BeZero(), - "Ord": Equal(uint8(2)), - }), - }), + "UnsupportedTypes": HaveLen(0), }), })) })