(structName, goFieldName string, arrType *ast.ArrayType, tokenPos token.Pos, pass *analysis.Pass)
| 323 | } |
| 324 | |
| 325 | func checkStructArrayType(structName, goFieldName string, arrType *ast.ArrayType, tokenPos token.Pos, pass *analysis.Pass) { |
| 326 | if starExpr, ok := arrType.Elt.(*ast.StarExpr); ok { |
| 327 | if ident, ok := starExpr.X.(*ast.Ident); ok && isBuiltinType(ident.Name) { |
| 328 | const msg = "change the %q field type to %q in the struct %q" |
| 329 | pass.Reportf(tokenPos, msg, goFieldName, "[]"+ident.Name, structName) |
| 330 | } |
| 331 | return |
| 332 | } |
| 333 | |
| 334 | if ident, ok := arrType.Elt.(*ast.Ident); ok && ident.Obj != nil { |
| 335 | if _, ok := ident.Obj.Decl.(*ast.TypeSpec).Type.(*ast.StructType); ok { |
| 336 | const msg = "change the %q field type to %q in the struct %q" |
| 337 | pass.Reportf(tokenPos, msg, goFieldName, "[]*"+ident.Name, structName) |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | func isBuiltinType(typeName string) bool { |
| 343 | return types.Universe.Lookup(typeName) != nil |
no test coverage detected
searching dependent graphs…