diff options
author | Teddy Wing | 2023-05-16 21:05:21 +0200 |
---|---|---|
committer | Teddy Wing | 2023-05-16 21:05:21 +0200 |
commit | ad4b4956a5ac8d08b271417687e354e5c66491a8 (patch) | |
tree | 8c551290d37768325add0f30345046a90a1291ed /gocapturedrefrace.go | |
parent | 2c3cbc5822e19a000b23a959ff70dd57be7757e2 (diff) | |
download | gocapturedrefrace-ad4b4956a5ac8d08b271417687e354e5c66491a8.tar.bz2 |
Report reference-type closure arguments
Diffstat (limited to 'gocapturedrefrace.go')
-rw-r--r-- | gocapturedrefrace.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/gocapturedrefrace.go b/gocapturedrefrace.go index 50a0297..c3d5d82 100644 --- a/gocapturedrefrace.go +++ b/gocapturedrefrace.go @@ -69,13 +69,22 @@ func run(pass *analysis.Pass) (interface{}, error) { fmt.Printf("funcLit params: %#v\n", funcLit.Type.Params.List) for _, arg := range funcLit.Type.Params.List { - fmt.Printf("funcLit param:") - - for _, argNameIdent := range arg.Names { - fmt.Printf("%#v, ", argNameIdent.Name) + fmt.Printf( + "funcLit param: %s ; type: %#v\n", + arg.Names[0].Name, + arg.Type, + ) + + _, ok := arg.Type.(*ast.StarExpr) + if !ok { + continue } - fmt.Println() + pass.Reportf( + arg.Pos(), + "reference %s in goroutine closure", + arg.Names[0], + ) } // scope := pass.TypesInfo.Scopes[funcLit] |