MCPcopy Create free account
hub / github.com/google/go-github / checkStructArrayType

Function checkStructArrayType

tools/structfield/structfield.go:325–340  ·  view source on GitHub ↗
(structName, goFieldName string, arrType *ast.ArrayType, tokenPos token.Pos, pass *analysis.Pass)

Source from the content-addressed store, hash-verified

323}
324
325func 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
342func isBuiltinType(typeName string) bool {
343 return types.Universe.Lookup(typeName) != nil

Calls 1

isBuiltinTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…