(pass *analysis.Pass, allowedTagNames, allowedTagTypes map[string]bool)
| 100 | } |
| 101 | |
| 102 | func run(pass *analysis.Pass, allowedTagNames, allowedTagTypes map[string]bool) (any, error) { |
| 103 | for _, file := range pass.Files { |
| 104 | ast.Inspect(file, func(n ast.Node) bool { |
| 105 | if n == nil { |
| 106 | return false |
| 107 | } |
| 108 | |
| 109 | t, ok := n.(*ast.TypeSpec) |
| 110 | if !ok { |
| 111 | return true |
| 112 | } |
| 113 | structType, ok := t.Type.(*ast.StructType) |
| 114 | if !ok { |
| 115 | return true |
| 116 | } |
| 117 | |
| 118 | // Check only exported |
| 119 | if !ast.IsExported(t.Name.Name) { |
| 120 | return true |
| 121 | } |
| 122 | |
| 123 | for _, field := range structType.Fields.List { |
| 124 | if field.Tag == nil || len(field.Names) == 0 { |
| 125 | continue |
| 126 | } |
| 127 | |
| 128 | processStructField(t.Name.Name, field, pass, allowedTagNames, allowedTagTypes) |
| 129 | } |
| 130 | |
| 131 | return true |
| 132 | }) |
| 133 | } |
| 134 | return nil, nil |
| 135 | } |
| 136 | |
| 137 | func processStructField(structName string, field *ast.Field, pass *analysis.Pass, allowedTagNames, allowedTagTypes map[string]bool) { |
| 138 | goField := field.Names[0] |
no test coverage detected