(structName string, goField *ast.Ident, field *ast.Field, structTag reflect.StructTag, tagType string, pass *analysis.Pass, allowedTagNames, allowedTagTypes map[string]bool)
| 144 | } |
| 145 | |
| 146 | func processTag(structName string, goField *ast.Ident, field *ast.Field, structTag reflect.StructTag, tagType string, pass *analysis.Pass, allowedTagNames, allowedTagTypes map[string]bool) { |
| 147 | tagName, ok := structTag.Lookup(tagType) |
| 148 | if !ok || tagName == "-" { |
| 149 | return |
| 150 | } |
| 151 | |
| 152 | hasOmitEmpty := strings.Contains(tagName, ",omitempty") |
| 153 | hasOmitZero := strings.Contains(tagName, ",omitzero") |
| 154 | |
| 155 | if hasOmitEmpty || hasOmitZero { |
| 156 | checkGoFieldType(structName, goField.Name, tagType, field, field.Pos(), pass, allowedTagTypes, hasOmitEmpty, hasOmitZero) |
| 157 | tagName = strings.ReplaceAll(tagName, ",omitzero", "") |
| 158 | tagName = strings.ReplaceAll(tagName, ",omitempty", "") |
| 159 | } |
| 160 | if tagType == "url" { |
| 161 | tagName = strings.ReplaceAll(tagName, ",comma", "") |
| 162 | } |
| 163 | checkGoFieldName(structName, goField.Name, tagType, tagName, goField.Pos(), pass, allowedTagNames) |
| 164 | } |
| 165 | |
| 166 | func checkAndReportInvalidTypesForOmitzero(structName, tagType, goFieldName string, fieldType ast.Expr, tokenPos token.Pos, pass *analysis.Pass) bool { |
| 167 | switch ft := fieldType.(type) { |
no test coverage detected
searching dependent graphs…