Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.

Commit 20d2db1

Browse files
committed
nil check on struct tag
1 parent 7e3f109 commit 20d2db1

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

definition_walker.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,19 @@ func (this *DefinitionVisitor) Visit(node ast.Node) (w ast.Visitor) {
149149
return nil
150150
}
151151

152-
jsonName, jsonOmitEmpty := parseJsonInfo(t.Tag.Value)
153-
if jsonName == "-" {
154-
return nil
155-
}
152+
var (
153+
jsonName string
154+
jsonOmitEmpty bool
155+
isRequired bool
156+
)
157+
if t.Tag != nil {
158+
jsonName, jsonOmitEmpty = parseJsonInfo(t.Tag.Value)
159+
if jsonName == "-" {
160+
return nil
161+
}
156162

157-
isRequired := parseValidateTag(t.Tag.Value)
163+
isRequired = parseValidateTag(t.Tag.Value)
164+
}
158165

159166
var desc string = parseMemberDescription(t.Doc.Text())
160167
if desc == "" {

0 commit comments

Comments
 (0)