@@ -91,14 +91,14 @@ func run(pass *analysis.Pass) (any, error) {
9191 return
9292 }
9393
94- results .insertFieldTagInfo (field , extractTagInfo (field .Tag ))
94+ results .insertFieldTagInfo (field , extractTagInfo (field , field .Tag ))
9595 })
9696
9797 return results , nil
9898}
9999
100100//nolint:cyclop
101- func extractTagInfo (tag * ast.BasicLit ) FieldTagInfo {
101+ func extractTagInfo (field * ast. Field , tag * ast.BasicLit ) FieldTagInfo {
102102 if tag == nil || tag .Value == "" {
103103 return FieldTagInfo {Missing : true }
104104 }
@@ -115,6 +115,12 @@ func extractTagInfo(tag *ast.BasicLit) FieldTagInfo {
115115 }
116116
117117 if tagValue == "" {
118+ if field .Names == nil { // Embedded field with `json:""`
119+ emptyJsonTagPrefix := `json:"`
120+ pos := tag .Pos () + token .Pos (strings .Index (tag .Value , emptyJsonTagPrefix )+ len (emptyJsonTagPrefix ))
121+ end := pos + token .Pos (1 )
122+ return FieldTagInfo {Inline : true , RawValue : "" , Pos : pos , End : end }
123+ }
118124 return FieldTagInfo {}
119125 }
120126
@@ -169,7 +175,7 @@ type FieldTagInfo struct {
169175 // OmitZero is true if the field has the omitzero option in the json tag.
170176 OmitZero bool
171177
172- // Inline is true if the field has the inline option in the json tag.
178+ // Inline is true if the json tag is ", inline", or if the field is embedded and the json tag is "" .
173179 Inline bool
174180
175181 // Missing is true when the field had no json tag.
0 commit comments