diff options
| -rw-r--r-- | gocapturedrefrace.go | 19 | ||||
| -rw-r--r-- | testdata/simple.go | 4 | 
2 files changed, 16 insertions, 7 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] diff --git a/testdata/simple.go b/testdata/simple.go index 9fdf7a5..772b58c 100644 --- a/testdata/simple.go +++ b/testdata/simple.go @@ -35,7 +35,7 @@ func argumentReference() {  	s := aStruct{field: 0} -	go func(s *aStruct) { -		s.field += 1 // want "reference s in goroutine closure" +	go func(s *aStruct) { // want "reference s in goroutine closure" +		s.field += 1  	}(&s)  } | 
