Skip to content

Commit f30fa98

Browse files
committed
fix: don't stop if one tag is invalid
1 parent 99abd22 commit f30fa98

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

parser/parse.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (p *Parser) parseStruct(spec *ast.TypeSpec) {
155155
var s *ast.StructType
156156
var ok bool
157157

158-
if s, ok = spec.Type.(*ast.StructType); ! ok {
158+
if s, ok = spec.Type.(*ast.StructType); !ok {
159159
return
160160
}
161161

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

174174
for _, f := range s.Fields.List {
175175
if f.Tag == nil || f.Tag.Value == "" {
176-
return
176+
continue
177177
}
178178

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

181181
if err != nil {
182-
return
182+
continue
183183
}
184184

185185
if tag.Type == "" {
@@ -207,6 +207,11 @@ func (p *Parser) parseTypeSpec(spec *ast.TypeSpec) {
207207
p.parseStruct(spec)
208208
case *ast.Ident:
209209
t := parseType(spec.Type)
210+
211+
if spec.Name.Name == t {
212+
return
213+
}
214+
210215
p.tMtx.Lock()
211216
defer p.tMtx.Unlock()
212217
p.types = append(p.types, &TypeDef{
@@ -219,7 +224,7 @@ func (p *Parser) parseTypeSpec(spec *ast.TypeSpec) {
219224
case *ast.SelectorExpr:
220225
st := spec.Type.(*ast.SelectorExpr)
221226
t := "any"
222-
if xv, ok := st.X.(*ast.Ident); ! ok {
227+
if xv, ok := st.X.(*ast.Ident); !ok {
223228
panic("unhandled case")
224229
} else {
225230
p.pMtx.Lock()

0 commit comments

Comments
 (0)