github.com/chenfeining/golangci-lint@v1.0.2-0.20230730162517-14c6c67868df/test/ruleguard/rangeExprCopy.go (about) 1 // go:build ruleguard 2 package ruleguard 3 4 import ( 5 "github.com/quasilyte/go-ruleguard/dsl" 6 ) 7 8 func RangeExprVal(m dsl.Matcher) { 9 m.Match(`for _, $_ := range $x { $*_ }`, `for _, $_ = range $x { $*_ }`). 10 Where(m["x"].Addressable && m["x"].Type.Size >= 512). 11 Report(`$x copy can be avoided with &$x`). 12 At(m["x"]). 13 Suggest(`&$x`) 14 }