Skip to content

Commit

Permalink
fix: don't stop if one tag is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
ihadeed committed Nov 20, 2019
1 parent 99abd22 commit f30fa98
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions parser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (p *Parser) parseStruct(spec *ast.TypeSpec) {
var s *ast.StructType
var ok bool

if s, ok = spec.Type.(*ast.StructType); ! ok {
if s, ok = spec.Type.(*ast.StructType); !ok {
return
}

Expand All @@ -173,13 +173,13 @@ func (p *Parser) parseStruct(spec *ast.TypeSpec) {

for _, f := range s.Fields.List {
if f.Tag == nil || f.Tag.Value == "" {
return
continue
}

tag, err := parseTags(f.Tag.Value)

if err != nil {
return
continue
}

if tag.Type == "" {
Expand Down Expand Up @@ -207,6 +207,11 @@ func (p *Parser) parseTypeSpec(spec *ast.TypeSpec) {
p.parseStruct(spec)
case *ast.Ident:
t := parseType(spec.Type)

if spec.Name.Name == t {
return
}

p.tMtx.Lock()
defer p.tMtx.Unlock()
p.types = append(p.types, &TypeDef{
Expand All @@ -219,7 +224,7 @@ func (p *Parser) parseTypeSpec(spec *ast.TypeSpec) {
case *ast.SelectorExpr:
st := spec.Type.(*ast.SelectorExpr)
t := "any"
if xv, ok := st.X.(*ast.Ident); ! ok {
if xv, ok := st.X.(*ast.Ident); !ok {
panic("unhandled case")
} else {
p.pMtx.Lock()
Expand Down

0 comments on commit f30fa98

Please sign in to comment.