package gorules
import "github.com/quasilyte/go-ruleguard/dsl"
func goRecover(m dsl.Matcher) {
// This `recover()` matching happens on AST (node) level,
// not on a text level.
m.Match(`go func () { $*body }`).
Where(m["body"].Contains(`recover()`)).
Report("called recover() inside go stmt")
}
package main
import "fmt"
func main() {
go func() {
rv := recover()
panic(rv)
}
}
Notes:
$a
will refer to top-level Match
matches